
^Yc           @   s  d  d l  Z  d  d l Z d  d l m Z m Z e Z e  j j d d  Z	 e j
 d d k ro d  d l m Z n d  d l m Z d e f d	     YZ d
 e f d     YZ d e f d     YZ d e f d     YZ e d d d  Z d e f d     YZ d e f d     YZ d d, d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d      YZ d! e f d"     YZ d# e f d$     YZ d% e f d&     YZ d' e f d(     YZ  i  Z! e" e" d)  Z# e" e" d*  Z$ e" d+  Z% d S(-   iN(   t
   CO_VARARGSt   CO_VARKEYWORDSt   reprt   reprlibi    i   (   t   format_exception_onlyt   Codec           B   s\   e  Z d  Z d   Z d   Z d   Z e d    Z e d    Z d   Z	 e
 d  Z RS(   s$    wrapper around Python code objects c         C   s   t  | d  s$ t j j |  } n  y, | j |  _ | j d |  _ | j |  _	 Wn$ t
 k
 rv t d | f   n X| |  _ d  S(   Nt   co_filenamei   s   not a code object: %r(   t   hasattrt   pyt   codet
   getrawcodeR   t   filenamet   co_firstlinenot   firstlinenot   co_namet   namet   AttributeErrort	   TypeErrort   raw(   t   selft   rawcode(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   __init__   s    c         C   s   |  j  | j  k S(   N(   R   (   R   t   other(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   __eq__   s    c         C   s   |  | k S(   N(    (   R   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   __ne__   s    c         C   s7   t  j j |  j j  } | j   s3 |  j j } n  | S(   ss    return a path object pointing to source code (note that it
        might not point to an actually existing file). (   R   t   patht   localR   R   t   check(   R   t   p(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR   !   s    c         C   s,   d d l  m } | j |  j  \ } } | S(   sM    return a py.code.Source object for the full source file of the code
        i(   t   source(   t   py._codeR   t
   findsourceR   (   R   R   t   fullt   _(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt
   fullsource-   s    c         C   s   t  j j |  j  S(   sJ    return a py.code.Source object for the code object's source only
        (   R   R	   t   SourceR   (   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR   5   s    c         C   sH   |  j  } | j } | r= | | j t @7} | | j t @7} n  | j |  S(   s    return a tuple with the argument names for the code object

            if 'var' is set True also return the names of the variable and
            keyword arguments when present
        (   R   t   co_argcountt   co_flagsR    R   t   co_varnames(   R   t   varR   t   argcount(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   getargs;   s    		(   t   __name__t
   __module__t   __doc__R   R   R   t   propertyR   R"   R   t   FalseR)   (    (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR      s   				t   Framec           B   sV   e  Z d  Z d   Z e d    Z d   Z d   Z d   Z d   Z	 e
 d  Z RS(   sg   Wrapper around a Python frame holding f_locals and f_globals
    in which expressions can be evaluated.c         C   sM   | j  d |  _ | j |  _ | j |  _ | |  _ t j j | j  |  _ d  S(   Ni   (	   t   f_linenot   linenot	   f_globalst   f_localsR   R   R	   R   t   f_code(   R   t   frame(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR   M   s
    	c         C   s8   |  j  j d k r" t j  j d  S|  j  j j |  j  S(   s    statement this frame is at t    N(   R	   R"   t   NoneR   R#   t   getstatementR1   (   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt	   statementT   s    c         K   s/   |  j  j   } | j |  t | |  j |  S(   s    evaluate 'code' in the frame

            'vars' are optional additional local variables

            returns the result of the evaluation
        (   R3   t   copyt   updatet   evalR2   (   R   R	   t   varsR3   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR<   [   s    c         K   s9   |  j  j   } | j |  t j j | |  j |  d S(   s^    exec 'code' in the frame

            'vars' are optiona; additional local variables
        N(   R3   R:   R;   R   t   builtint   exec_R2   (   R   R	   R=   R3   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR?   f   s    c         C   s   t  j j |  S(   sL    return a 'safe' (non-recursive, one-line) string repr for 'object'
        (   R   t   iot   saferepr(   R   t   object(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR   o   s    c         C   s   | S(   N(    (   R   RB   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   is_truet   s    c         C   sY   g  } xL |  j  j |  D]8 } y | j | |  j | f  Wq t k
 rP q Xq W| S(   s    return a list of tuples (name, value) for all arguments

            if 'var' is set True also include the variable and keyword
            arguments when present
        (   R	   R)   t   appendR3   t   KeyError(   R   R'   t   retvalt   arg(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR)   w   s    (   R*   R+   R,   R   R-   R9   R<   R?   R   RC   R.   R)   (    (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR/   I   s   						t   TracebackEntryc           B   s   e  Z d  Z d Z d Z d   Z d   Z e d    Z	 e d    Z
 d   Z e d    Z e d    Z d   Z e e d d d	  Z d
   Z d   Z d d  Z e e  Z d   Z d   Z d   Z e e d d d  Z RS(   s    a single entry in a traceback c         C   s   | |  _  | j d |  _ d  S(   Ni   (   t	   _rawentryt	   tb_linenoR1   (   R   t   rawentry(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR      s    	c         C   s   | d k s t   | |  _ d  S(   Nt   shortt   long(   s   shorts   long(   t   AssertionErrort   _repr_style(   R   t   mode(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   set_repr_style   s    c         C   s   t  j j |  j j  S(   N(   R   R	   R/   RI   t   tb_frame(   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR5      s    c         C   s   |  j  |  j j j S(   N(   R1   R5   R	   R   (   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   relline   s    c         C   s   d |  j  j j |  j d f S(   Ns   <TracebackEntry %s:%d>i   (   R5   R	   R   R1   (   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   __repr__   s    c         C   s   |  j  j j } | j |  j  S(   s1    py.code.Source object for the current statement (   R5   R	   R"   R8   R1   (   R   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR9      s    c         C   s   |  j  j j S(   s    path to the source code (   R5   R	   R   (   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR      s    c         C   s
   |  j  j S(   N(   R5   R3   (   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt	   getlocals   s    s   locals of underlaying framec         C   sz   |  j  d k rs t |  j  j   } t j j | |  j d t	 } t
 | t  sg t d | f   n  | |  _  n  |  j  S(   st   Reinterpret the failing statement and returns a detailed information
           about what operations are performed.t   should_fails    interpret returned non-string %rN(   t   exprinfoR7   t   strR9   t   stripR   R	   t   _reinterpretR5   t   Truet
   isinstanceR   (   R   R   t   x(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   reinterpret   s    c         C   s   t  |  j j j d  S(   Ni    (   t   maxR5   R	   R   (   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   getfirstlinesource   s    c   	      C   s   d d l  m } |  j j j } | d k r/ d Sd } } | d k	 rx |  j j j } | d k	 rx | j | d  } qx n  |  j   } y% | |  j	 | d | \ } } } Wn t
 k
 r |  j	 d } n X| d k	 r | | | <n  | | | !S(   s    return failing source code. i(   t   getstatementrange_astt   astnodei   N(   t   py._code.sourceRa   R5   R	   R"   R7   R   t   getR`   R1   t   SyntaxError(	   R   t   astcacheRa   R   t   keyRb   t   startR!   t   end(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt	   getsource   s$    
c         C   sQ   y |  j  j d SWn8 t k
 rL y |  j  j d SWqM t k
 rH t SXn Xd S(   s    return True if the current frame has a var __tracebackhide__
            resolving to True

            mostly for internal use
        t   __tracebackhide__N(   R5   R3   RE   R2   R.   (   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   ishidden   s    c         C   s   y t  |  j  } Wn t j j k
 r2 d } n X|  j j j } y t  |  j  j	   } Wn  t
 k
 rq   n d } n Xd | |  j d | | f S(   Ns   ???s     File %r:%d in %s
  %s
i   (   RX   R   R   t   errort   ErrorR5   R	   R   R9   t   lstript   KeyboardInterruptR1   (   R   t   fnR   t   line(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   __str__   s    

c         C   s   |  j  j j j S(   N(   R5   R	   R   R   (   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR      s    s   co_name of underlaying codeN(   R*   R+   R,   R7   RO   RW   R   RQ   R-   R5   RS   RT   R9   R   RU   t   localsR^   R`   Rj   R   Rl   Rs   R   (    (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyRH      s(   									t	   Tracebackc           B   s\   e  Z d  Z e Z d   Z d d d d d  Z d   Z d   d  Z	 d   Z
 d   Z RS(	   s_    Traceback objects encapsulate and offer higher level
        access to Traceback entries.
    c            sK   t  | d  r7   f d   } t j   | |   n t j   |  d S(   s0    initialize from given python traceback object. t   tb_nextc         3   s.   x' |  d  k	 r)   j |   V|  j }  q Wd  S(   N(   R7   t   EntryRv   (   t   cur(   R   (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   f   s    N(   R   t   listR   (   R   t   tbRy   (    (   R   s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR      s    c         C   s   x |  D] } | j  j } | j } | d k s: | | k r | d k sf t | d  sf | j |  r | d k s | j | k r | d k s | j  j j | k r t | j	  Sq W|  S(   s   return a Traceback instance wrapping part of this Traceback

            by provding any combination of path, lineno and firstlineno, the
            first frame to start the to-be-returned traceback is determined

            this allows cutting the first part of a Traceback instance e.g.
            for formatting reasons (removing some uninteresting bits that deal
            with handling of the exception/traceback)
        t   reltoN(
   R5   R	   R   R7   R   R|   R1   R   Ru   RI   (   R   R   R1   R   t   excludepathR]   R	   t   codepath(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   cut  s    
	!c         C   sI   t  t |   j |  } t | t t d    rE |  j |  } n  | S(   Ni    (   t   superRu   t   __getitem__R\   t   typet   slicet	   __class__(   R   Rg   t   val(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR     s    c         C   s   |  j    S(   N(   Rl   (   R]   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   <lambda>!  s    c         C   s   t  t | |    S(   ss   return a Traceback instance with certain items removed

            fn is a function that gets a single argument, a TracebackItem
            instance, and should return True when the item should be added
            to the Traceback, False when not

            by default this removes all the TracebackItems which are hidden
            (see ishidden() above)
        (   Ru   t   filter(   R   Rq   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR   !  s    
c         C   sJ   x? t  d t |   d d  D]  } |  | } | j   s | Sq W|  d S(   sc    return last non-hidden traceback entry that lead
        to the exception of a traceback.
        ii   (   t   ranget   lenRl   (   R   t   it   entry(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   getcrashentry-  s
    $
c   	   	   C   s   i  } x t  |   D] \ } } | j j j t | j j j  | j f } | j | g   } | r | j } | j } x9 | D]. } | j	 | j
 t d | d |  rz | Sqz Wn  | j | j j  q Wd S(   s    return the index of the frame/TracebackItem where recursion
            originates if appropriate, None if no recursion occurred
        t   __recursioncache_locals_1t   __recursioncache_locals_2N(   t	   enumerateR5   R	   R   t   idR   R1   t
   setdefaultR3   RC   R<   t   co_equalRD   R7   (	   R   t   cacheR   R   Rg   t   lRy   t   loct   otherloc(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   recursionindex7  s    *		N(   R*   R+   R,   RH   Rw   R   R7   R   R   R   R   R   (    (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyRu      s   			
s6   __recursioncache_locals_1 == __recursioncache_locals_2t   ?R<   t   ExceptionInfoc           B   st   e  Z d  Z d Z d d d  Z d   Z e d  Z d   Z	 d   Z
 e d e e e d  Z d	   Z d
   Z RS(   sX    wraps sys.exc_info() objects and offers
        help for navigating the traceback.
    R6   c         C   s   | d  k r t j   } | d  k r t | d t  r t | d d d   } | d  k rl t | d  } n  | r | j d  r d |  _ q q n  | |  _	 | d |  _
 | d |  _ | d |  _ |  j
 j |  _ t j j |  j  |  _ d  S(   Ni   t   msgs   assert s   AssertionError: i    i   (   R7   t   syst   exc_infoR\   RN   t   getattrRX   t
   startswitht
   _striptextt   _excinfoR   t   valueR{   R*   t   typenameR   R	   Ru   t	   traceback(   R   t   tupRW   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR   W  s    	c         C   s   d |  j  t |  j  f S(   Ns   <ExceptionInfo %s tblen=%d>(   R   R   R   (   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyRT   l  s    c         C   se   t  |  j |  j  } d j |  } | j   } | ra | j |  j  ra | t |  j  } qa n  | S(   s.   return the exception as a string

            when 'tryshort' resolves to True, and the exception is a
            py.code._AssertionError, only the actual exception part of
            the exception representation is returned (so 'AssertionError: ' is
            removed from the beginning)
        R6   (   R   R   R   t   joint   rstripR   R   R   (   R   t   tryshortt   linest   text(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   exconlyo  s    c         C   s   t  |  j |  S(   s4    return True if the exception is an instance of exc (   R\   R   (   R   t   exc(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   errisinstance  s    c         C   sQ   |  j  d t  } |  j j   } | j j j j | j } } t	 | | d |  S(   NR   i   (
   R   R[   R   R   R5   R	   R   R   R1   t   ReprFileLocation(   R   R   R   R   R1   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   _getreprcrash  s    RM   c         C   s~   | d k rJ t  t t j j j |  j |  j |  j d j   |  j	    St
 d | d | d | d | d |  } | j |   S(   sA   return str()able representation of this exception info.
            showlocals: show locals per traceback entry
            style: long|short|no|native traceback style
            tbfilter: hide entries (where __tracebackhide__ is true)

            in case of style==native, tbfilter and showlocals is ignored.
        t   nativei    t
   showlocalst   stylet   abspatht   tbfiltert   funcargs(   t   ReprExceptionInfot   ReprTracebackNativeR   t   stdR   t   format_exceptionR   R   RI   R   t   FormattedExcinfot   repr_excinfo(   R   R   R   R   R   R   t   fmt(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   getrepr  s    	c         C   s9   |  j  d } t | j | j d |  j    } t |  S(   Nii   (   R   R   R   R1   R   RX   (   R   R   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyRs     s    "c         C   s9   |  j  d } t | j | j d |  j    } | j   S(   Nii   (   R   R   R   R1   R   t   __unicode__(   R   R   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR     s    "N(   R*   R+   R,   R   R7   R   RT   R.   R   R   R   R[   R   Rs   R   (    (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR   R  s   				R   c           B   s   e  Z d  Z d Z d Z e d e e e d  Z d   Z d   Z	 d   Z
 d   Z d	 d e d
  Z d e d  Z d   Z d d  Z d   Z d   Z d   Z RS(   s@    presenting information about failing Functions and Generators. t   >t   ERM   c         C   s:   | |  _  | |  _ | |  _ | |  _ | |  _ i  |  _ d  S(   N(   R   R   R   R   R   Rf   (   R   R   R   R   R   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR     s    					c         C   s   y# t  | j t |  d   } WnL t k
 r9   n9 y t  | d  } Wqr t k
 rf   qr d SXn Xd t |  t | j    S(   Ni   ii    i   (   RX   R8   R   Rp   Ro   (   R   R   t   s(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt
   _getindent  s    #	c         C   s1   | j  |  j  } | d  k	 r- | j   } n  | S(   N(   Rj   Rf   R7   t   deindent(   R   R   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   _getentrysource  s    c         C   s   t  j j |  S(   N(   R   R@   RA   (   R   t   obj(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt	   _saferepr  s    c         C   s_   |  j  r[ g  } x? | j j d t  D]( \ } } | j | |  j |  f  q% Wt |  Sd  S(   NR'   (   R   R5   R)   R[   RD   R   t   ReprFuncArgs(   R   R   t   argst   argnamet   argvalue(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt	   repr_args  s
    	" ic   	      C   sS  g  } | d	 k s' | t | j  k rB t j j d  } d } n  | d k  ra | t |  7} n  d } | r | j | | j | j    nu x& | j |  D] } | j | |  q W| j |  j d | j |  x* | j | d D] } | j | |  q W| d	 k	 rO| rd n |  j	 |  } | j
 |  j | d | d t  n  | S(
   s.    return formatted and marked up source lines. s   ???i    s       s      i   i   t   indentt   markallN(   R7   R   R   R   R	   R#   RD   RY   t   flow_markerR   t   extendt   get_exconlyR[   (	   R   R   t
   line_indext   excinfoRL   R   t   space_prefixRr   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt
   get_source  s$    !	!%i   c         C   sq   g  } d | } | j  d t  j d  } |  j | d } x. | D]& } | j | |  | sC | } qC qC W| S(   Nt    R   s   
i   (   R   R[   t   splitt   fail_markerRD   (   R   R   R   R   R   t   exlinest
   failindentRr   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR     s    
c         C   s   |  j  r g  } g  | D] } | d d k r | ^ q } | j   xZ | D]R } | | } | d k ru | j d  qI |  j |  } | j d | | f  qI Wt |  Sd  S(   Ni    t   @t   __builtins__s   __builtins__ = <builtins>s
   %-10s = %s(   R   t   sortRD   R   t
   ReprLocals(   R   Rt   R   R   t   keysR   R   t   str_repr(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   repr_locals  s    	)

c         C   s  |  j  |  } | d  k r6 t j j d  } d } n | j t | j   d  } g  } | j } | d  k ry |  j	 } n  | d
 k ra| d k } | s |  j
 |  n d  } |  j | | | d | }	 | j |	  | r d | j }
 n | r | j p d }
 |  j | j  } t | | j d |
  } d  } | sK|  j | j  } n  t | | | | |  S| r| j |  j | d d	  n  t | d  d  d  |  S(   Ns   ???i    RL   RM   s   in %sR6   i   R   i   (   s   shorts   long(   R   R7   R   R	   R#   R1   R_   R`   RO   R   R   R   R   R   R   t	   _makepathR   R   R   Rt   t	   ReprEntryR   (   R   R   R   R   R   R   R   RL   t   reprargsR   t   messageR   t   filelocreprt
   localsrepr(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   repr_traceback_entry  s4    		c         C   sh   |  j  sd y t j j   j |  } Wn t k
 r9 | SXt |  t t |   k  rd | } qd n  | S(   N(   R   R   R   R   t   bestrelpatht   OSErrorR   RX   (   R   R   t   np(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR   /  s    	c         C   s   | j  } |  j r! | j   } n  d  } | j t  r] d t | j  k r] | j   } q] n  | d } g  } d  } xg t	 |  D]Y \ } } | | k r | p d  }	 |  j
 | |	  }
 | j |
  | | k r d } Pq q Wt | | d |  j S(   Ns    maximum recursion depth exceededis/   !!! Recursion detected (same locals & position)R   (   R   R   R   R7   R   t   RuntimeErrorRX   R   R   R   R   RD   t   ReprTracebackR   (   R   R   R   R   t   lastt   entriest	   extralinet   indexR   t   einfot	   reprentry(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   repr_traceback9  s$    		
c         C   s(   |  j  |  } | j   } t | |  S(   N(   R   R   R   (   R   R   t   reprtracebackt	   reprcrash(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR   M  s    N(   R*   R+   R,   R   R   R.   R[   R   R   R   R   R   R7   R   R   R   R   R   R   R   (    (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR     s   					 	
	t   TerminalReprc           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   s5   |  j    } t j d d k  r1 | j d  } n  | S(   Ni    i   s   utf-8(   R   R   t   version_infot   encode(   R   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyRs   S  s    c         C   sA   t  j j   } t  j j d |  } |  j |  | j   j   S(   Nt   file(   R   R@   t   TextIOt   TerminalWritert
   toterminalt   getvalueRY   (   R   R@   t   tw(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR   Y  s    c         C   s   d |  j  t |   f S(   Ns   <%s instance at %0x>(   R   R   (   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyRT   a  s    (   R*   R+   Rs   R   RT   (    (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR   R  s   		R   c           B   s&   e  Z d    Z d d  Z d   Z RS(   c         C   s   | |  _  | |  _ g  |  _ d  S(   N(   R   R   t   sections(   R   R   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR   f  s    		t   -c         C   s   |  j  j | | | f  d  S(   N(   R   RD   (   R   R   t   contentt   sep(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt
   addsectionk  s    c         C   sN   |  j  j |  x7 |  j D], \ } } } | j | |  | j |  q Wd  S(   N(   R   R   R   R  Rr   (   R   R   R   R   R  (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR   n  s    (   R*   R+   R   R  R   (    (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR   e  s   	R   c           B   s    e  Z d  Z d   Z d   Z RS(   s   _ c         C   s   | |  _  | |  _ | |  _ d  S(   N(   t   reprentriesR   R   (   R   R  R   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR   w  s    		c         C   s   d  } x t |  j  D] \ } } | j d k rA | j d  n  | j |  | t |  j  d k  r |  j | d } | j d k s | j d k r | j d k r | j |  j  q q q W|  j	 r | j |  j	  n  d  S(   NRM   R6   i   RL   (
   R7   R   R  R   Rr   R   R   R  t   entrysepR   (   R   R   t
   last_styleR   R   t
   next_entry(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR   |  s    	(   R*   R+   R  R   R   (    (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR   t  s   	R   c           B   s   e  Z d    Z RS(   c         C   s(   d |  _  t |  g |  _ d  |  _ d  S(   NR   (   R   t   ReprEntryNativeR  R7   R   (   R   t   tblines(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR     s    	(   R*   R+   R   (    (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR     s   R  c           B   s    e  Z d  Z d   Z d   Z RS(   R   c         C   s   | |  _  d  S(   N(   R   (   R   R  (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR     s    c         C   s   | j  d j |  j   d  S(   NR6   (   t   writeR   R   (   R   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR     s    (   R*   R+   R   R   R   (    (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR    s   	R   c           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s   _ c         C   s1   | |  _  | |  _ | |  _ | |  _ | |  _ d  S(   N(   R   t   reprfuncargst
   reprlocalst   reprfilelocR   (   R   R   R
  R  R   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR     s
    				c         C   s  |  j  d k r_ |  j j |  x9 |  j D]. } | j d  } | j | d t d | q) Wd  S|  j r{ |  j j |  n  x9 |  j D]. } | j d  } | j | d t d | q W|  j r | j d  |  j j |  n  |  j r|  j r| j d  n  |  j j |  n  d  S(   NRL   s   E   t   boldt   redR6   (	   R   R  R   R   R   Rr   R[   R
  R  (   R   R   Rr   R  (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR     s$    				c         C   s#   d d j  |  j  |  j |  j f S(   Ns   %s
%s
%ss   
(   R   R   R  R  (   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyRs     s    (   R*   R+   t	   localssepR   R   Rs   (    (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR     s   		R   c           B   s   e  Z d    Z d   Z RS(   c         C   s%   t  |  |  _ | |  _ | |  _ d  S(   N(   RX   R   R1   R   (   R   R   R1   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR     s    	c         C   sU   |  j  } | j d  } | d k r1 | |  } n  | j d |  j |  j | f  d  S(   Ns   
is	   %s:%s: %s(   R   t   findRr   R   R1   (   R   R   R   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR     s
    	(   R*   R+   R   R   (    (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR     s   	R   c           B   s   e  Z d    Z d   Z RS(   c         C   s   | |  _  d  S(   N(   R   (   R   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR     s    c         C   s%   x |  j  D] } | j |  q
 Wd  S(   N(   R   Rr   (   R   R   Rr   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR     s    (   R*   R+   R   R   (    (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR     s   	R   c           B   s   e  Z d    Z d   Z RS(   c         C   s   | |  _  d  S(   N(   R   (   R   R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR     s    c         C   s   |  j  r d } x |  j  D]{ \ } } d | | f } t |  t |  d | j k rw | rn | j |  n  | } q | r | d | 7} q | } q W| r | j |  n  | j d  n  d  S(   NR6   s   %s = %si   s   , (   R   R   t	   fullwidthRr   (   R   R   t	   linesofarR   R   t   ns(    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR     s    	#	
(   R*   R+   R   R   (    (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR     s   	c         C   s   |  rS d d l  m }  t j d g   } | j t j j j  |  j t j j _ n  | r t j d g   } | j t j j j	  t j
 j	 t j j _	 n  d S(   s?    put compile and AssertionError builtins to Python's builtins. i(   t	   assertionRN   t   compileN(   R   R  t   oldbuiltinsR   RD   R   R>   t   builtinsRN   R  R	   (   R  R  R   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   patch_builtins  s    c         C   sH   |  r" t  d j   t j j _ n  | rD t  d j   t j j _ n  d S(   sB    remove compile and AssertionError builtins from Python builtins. RN   R  N(   R  t   popR   R>   R  RN   R  (   R  R  (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   unpatch_builtins  s    c         C   s   y |  j  SWn t k
 r t |  d |   }  t |  d |   }  t |  d |   }  t |  d |   }  | r t |  d  r t |  d  r t j j j |   r t |  j	 d t
 } t | d  r | Sq n  |  SXd S(	   s(    return code object for given function. t   im_funct	   func_codeR4   t   __code__R   t   __call__t   trycallN(   R  R   R   R   R   R   t   inspectt   isclassR
   R  R.   (   R   R  R]   (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyR
     s    %
(    (&   R   R   R   R    R   R   t   builtin_reprR>   t
   _tryimportR   R   R   R   t   py._code._py2tracebackRB   R   R/   RH   Rz   Ru   R  R   R   R   R   R   R   R   R  R   R   R   R   R  R[   R  R  R
   (    (    (    s)   /tmp/pip-build-hU8Cw8/py/py/_code/code.pyt   <module>   s8   ;<qYW	%