
Ã|j‰  ã               @   sA   d  Z  d d l Z d d l m Z d d d d d d d „ Z d S)z�
backports.makefile
~~~~~~~~~~~~~~~~~~

Backports the Python 3 ``socket.makefile`` method for use with anything that
wants to create a "fake" socket object.
é    N)ÚSocketIOÚrc             C   s„  t  | ƒ d d d h k s. t d | f ƒ ‚ d | k } d | k pJ | } | s_ | s_ t ‚ d | k } d }	 | r� |	 d 7}	 | r‘ |	 d 7}	 t |  |	 ƒ }
 |  j d 7_ | d k rÁ d
 } | d k  rÖ t j } | d k rø | sô t d	 ƒ ‚ |
 S| r| rt j |
 |
 | ƒ } n9 | r7t j |
 | ƒ } n | sCt ‚ t j	 |
 | ƒ } | r_| St j
 | | | | ƒ } | | _ | S)z:
    Backport of ``socket.makefile`` from Python 3.5.
    r   ÚwÚbz&invalid mode %r (only r, w, b allowed)Ú é   Nr   z!unbuffered streams must be binaryéÿÿÿÿ)ÚsetÚ
ValueErrorÚAssertionErrorr   Z_makefile_refsÚioÚDEFAULT_BUFFER_SIZEÚBufferedRWPairÚBufferedReaderÚBufferedWriterÚTextIOWrapperÚmode)Úselfr   Ú	bufferingÚencodingÚerrorsÚnewlineÚwritingÚreadingÚbinaryÚrawmodeÚrawÚbufferÚtext© r   úF/tmp/pip-build-1hwfuv5s/urllib3/urllib3/packages/backports/makefile.pyÚbackport_makefile   s@    

		r!   )Ú__doc__r   Úsocketr   r!   r   r   r   r    Ú<module>   s   