
вEbc           @   s>   d  Z  d d l Z d d l m Z d d d d d d  Z d S(   s   
backports.makefile
~~~~~~~~~~~~~~~~~~

Backports the Python 3 ``socket.makefile`` method for use with anything that
wants to create a "fake" socket object.
iN(   t   SocketIOt   rc         C   s  t  |  d d d h k s1 t d | f   n  d | k } d | k pM | } | sb | sb t  d | k } d }	 | r |	 d 7}	 n  | r |	 d 7}	 n  t |  |	  }
 |  j d 7_ | d
 k r d } n  | d k  r t j } n  | d k r
| st d	   n  |
 S| r.| r.t j |
 |
 |  } n9 | rIt j	 |
 |  } n | sUt  t j
 |
 |  } | rq| St j | | | |  } | | _ | S(   s:   
    Backport of ``socket.makefile`` from Python 3.5.
    R   t   wt   bs&   invalid mode %r (only r, w, b allowed)t    i   ii    s!   unbuffered streams must be binaryN(   t   sett
   ValueErrort   AssertionErrorR    t   _makefile_refst   Nonet   iot   DEFAULT_BUFFER_SIZEt   BufferedRWPairt   BufferedReadert   BufferedWritert   TextIOWrappert   mode(   t   selfR   t	   bufferingt   encodingt   errorst   newlinet   writingt   readingt   binaryt   rawmodet   rawt   buffert   text(    (    sL   /tmp/pip-build-UPPWic/pip/pip/_vendor/urllib3/packages/backports/makefile.pyt   backport_makefile   s@    		(   t   __doc__R
   t   socketR    R	   R   (    (    (    sL   /tmp/pip-build-UPPWic/pip/pip/_vendor/urllib3/packages/backports/makefile.pyt   <module>   s   