ó
B¨Õ\c           @   s…   d  Z  d d l Z d d l Z d „  Z d Z y" e j ƒ  d k rN e ƒ  Z n  Wn, e k
 r} Z e j	 j
 d j e ƒ ƒ n X[ d S(   sc   
Taken verbatim from Jinja2.

https://github.com/mitsuhiko/jinja2/blob/master/jinja2/debug.py#L267
iÿÿÿÿNc             sg  d d l  ‰ d d l m ‰  t ˆ j d ƒ r: ˆ j }  n	 ˆ j }  d ˆ j f d „  ƒ  Y} d |  f d ˆ j | ƒ f g | _	 t t
 d	 ƒ ró d ˆ j f d
 „  ƒ  Y} d ˆ j | ƒ f d ˆ j | ƒ f d |  f d ˆ j | ƒ f g | _	 n  d | f d „  ƒ  Y‰ d ˆ j ˆ ƒ f d ˆ j | ƒ f d ˆ j f d ˆ j f g ˆ _	 ‡  ‡ ‡ f d †  } | S(   sñ   This function implements a few ugly things so that we can patch the
    traceback objects.  The function returned allows resetting `tb_next` on
    any python traceback object.  Do not attempt to use this on non cpython
    interpreters
    iÿÿÿÿN(   t   TracebackTypet   Py_InitModule4_64t	   _PyObjectc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s,   lib/python2.7/site-packages/tblib/cpython.pyR      s   t	   ob_refcntt   ob_typet
   getobjectsc           B   s   e  Z RS(    (   R   R   (    (    (    s,   lib/python2.7/site-packages/tblib/cpython.pyR   $   s   t   _ob_nextt   _ob_prevt
   _Tracebackc           B   s   e  Z RS(    (   R   R   (    (    (    s,   lib/python2.7/site-packages/tblib/cpython.pyR
   .   s   t   tb_nextt   tb_framet   tb_lastit	   tb_linenoc            så   t  |  ˆ  ƒ o' | d k p' t  | ˆ  ƒ s9 t d ƒ ‚ n  ˆ j t |  ƒ ƒ } |  j d k	 r‡ ˆ j t |  j ƒ ƒ } | j d 8_ n  | d k r« ˆ j ˆ ƒ ƒ  | _ n6 ˆ j t | ƒ ƒ } | j d 7_ ˆ j | ƒ | _ d S(   s0   Set the tb_next attribute of a traceback object.s/   tb_set_next arguments must be traceback objectsi   N(	   t
   isinstancet   Nonet	   TypeErrort   from_addresst   idR   R   t   POINTERt   pointer(   t   tbt   nextt   objt   old(   R    R
   t   ctypes(    s,   lib/python2.7/site-packages/tblib/cpython.pyt   tb_set_next8   s    *(   R   t   typesR    t   hasattrt	   pythonapit   c_int64t   c_intt	   StructureR   t   _fields_t   sys(   t   _Py_ssize_tR   R   (    (   R    R
   R   s,   lib/python2.7/site-packages/tblib/cpython.pyt   _init_ugly_crap
   s*    			t   CPythons*   Failed to initialize cpython support: {!r}(   t   __doc__t   platformR#   R%   R   R   t   python_implementationt	   Exceptiont   exct   stderrt   writet   format(    (    (    s,   lib/python2.7/site-packages/tblib/cpython.pyt   <module>   s   	@