+
    DfjY                       R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t	 ^ RIH
t
 ^ RIHt ^ RIHtHtHt ^ RIHt ^ RIHt ^ R	IHt ]! R
]R]3,          R7      t^ s^t ! R R]4      tR#R ltRt ! R R]4      tR t  ! R R4      t! ! R R4      t" ! R R4      t#. t$R R lt% ! R R]&4      t'R t(Rt)RRRR ]'PT                  3R! lt+R" t,R# )$z9
Asynchronous-friendly error mechanism.

See L{Failure}.
)annotationsN)partial)getmro)StringIO)CallableNoReturnTypeVar)Version)reflect)deprecatedProperty_T_Callable.)boundc                      ] tR t^&tRtR# )DefaultException N)__name__
__module____qualname____firstlineno____static_attributes__r       8/usr/lib/python3/dist-packages/twisted/python/failure.pyr   r   &   s    r   r   c           
        VR9  d   \        RV: R24      hTpVR8X  d!   V  F  w  rErgpV! V RV RV R24       K  	  R# VR8X  dS   V  FJ  w  rErgpV! R	V R
V RV R24       V! R\        P                  ! WV4      P                  4       ,          4       KL  	  R# VR8X  d)   V  F  w  rErgpV! RWVV3,          4       K  	  V! R4       R# VR8X  dw   V  Fn  w  rErgpV! RWVV3,          4       V! R4       V F  w  rV! RV	 R\	        V
4       R24       K  	  V! R4       V F  w  rV! RV	 R\	        V
4       R24       K  	  Kp  	  R# R# )a`  
Format and write frames.

@param frames: is a list of frames as used by Failure.frames, with
    each frame being a list of
    (funcName, fileName, lineNumber, locals.items(), globals.items())
@type frames: list
@param write: this will be called with formatted strings.
@type write: callable
@param detail: Four detail levels are available:
    default, brief, verbose, and verbose-vars-not-captured.
    C{Failure.printDetailedTraceback} uses the latter when the caller asks
    for verbose, but no vars were captured, so that an explicit warning
    about the missing data is shown.
@type detail: string
defaultbriefverboseverbose-vars-not-capturedzKDetail must be default, brief, verbose, or verbose-vars-not-captured. (not ):
z  File "z", line z, in z    %s
z%s:%d: %s(...)
zA [Capture of Locals and Globals disabled (use captureVars=True)]
z [ Locals ]
z  z : z ( Globals )
N)r   r   r   r   )
ValueError	linecachegetlinestriprepr)frameswritedetailwmethodfilenamelineno	localVars
globalVarsnamevals   &&&        r   format_framesr0   *   s   " QQ5;>
 	
 	A?E;Ff
!F81VHB/0 @F	9	?E;Ff
(6(%xrBCj9,,X>DDFFG @F 
.	.?E;Ff Hf#==> @F	
NO	9	?E;Ff Hf#==>o&	BtfCS	{"-. ''	BtfCS	{"-. ( @F 
r   z--- <exception caught here> ---c                      ] tR t^\tRtRtR# )NoCurrentExceptionErrorz~
Raised when trying to create a Failure from the current interpreter
exception state and there is no current exception state.
r   N)r   r   r   r   __doc__r   r   r   r   r2   r2   \   s    r   r2   c                    \        V 4      ^ 8  g   Q R4       hRp\        V ^ ,          V4      p\        V4      ;r#V R,           F*  p\        WA4      p\        V4      Vn        VP                  pK,  	  V# )z
Construct a fake traceback object using a list of frames.

It should have the same API as stdlib to allow interaction with
other tools.

@param tbFrames: [(methodname, filename, lineno, locals, globals), ...]
zMust pass some framesN:   NN)len_Frame_TracebackFrametb_next)tbFramesstackfirstTbtbsfs   &    r   
_Tracebackr?   c   sx     x=1555 E 8A;&E"5))Grllr!$U+
ZZ  Nr   c                       ] tR t^tRtR tRtR# )r8   ze
Fake traceback object which can be passed to functions in the standard
library L{traceback} module.
c                d    Wn         VP                  V n        VP                  V n        RV n        R# )z
@param frame: _Frame object
N)tb_framef_lineno	tb_linenof_lastitb_lastir9   )selfframes   &&r   __init___TracebackFrame.__init__   s&     r   )rB   rF   rD   r9   Nr   r   r   r   r3   rI   r   r   r   r   r8   r8      s    
r   r8   c                       ] tR t^tRtR tRtR# )r7   a(  
A fake frame object, used by L{_Traceback}.

@ivar f_code: fake L{code<types.CodeType>} object
@ivar f_lineno: line number
@ivar f_globals: fake f_globals dictionary (usually empty)
@ivar f_locals: fake f_locals dictionary (usually empty)
@ivar f_back: previous stack frame (towards the caller)
c                   Vw  r4rVp\        W44      V n        WPn        \        T;'       g    / 4      V n        \        T;'       g    / 4      V n        W n        ^ V n        \        \        4      P                  4       V n        RV n        R# )z
@param frameinfo: (methodname, filename, lineno, locals, globals)
@param back: previous (older) stack frame
@type back: C{frame}
N)_Codef_coderC   dict	f_globalsf_localsf_backrE   varsbuiltinscopy
f_builtinsf_trace)rG   	frameinfobackr.   r*   r+   localzglobalzs   &&&     r   rI   _Frame.__init__   sl     3</D+gmm,V\\r*x.--/r   )rS   rW   rO   rQ   rE   rC   rR   rX   NrK   r   r   r   r7   r7      s    r   r7   c                  &    ] tR t^tRtR tR tRtR# )rN   z
A fake code object, used by L{_Traceback} via L{_Frame}.

It is intended to have the same API as the stdlib code type to allow
interoperation with other tools based on that interface.
c                	    Wn         W n        R V n        ^ V n        ^ V n        . V n        R V n        RV n        RV n        ^ V n	        RV n
        ^ V n        ^ V n        RV n        ^ V n        ^ V n        R# )r   Nr   )co_nameco_filename	co_lnotabco_firstlinenoco_argcountco_varnamesco_codeco_cellvars	co_constsco_flagsco_freevarsco_posonlyargcountco_kwonlyargcountco_names
co_nlocalsco_stacksize)rG   r.   r*   s   &&&r   rI   _Code.__init__   sw    #"#!"r   c                	    R# )N))NNNNr   rG   s   &r   co_positions_Code.co_positions   s    **r   )rd   rg   rf   rh   ra   rc   ri   rj   rl   rb   r`   rm   rn   rk   ro   re   N)r   r   r   r   r3   rI   rs   r   r   r   r   rN   rN      s    $+r   rN   c                    V ^8  d   QhRRRR/# )   fr   returnr   )formats   "r   __annotate__rz      s      ; ; r   c                D    \         P                  V P                  4       V # )z
Mark the given callable as extraneous to inlineCallbacks exception
reporting; don't show these functions.

@param f: a function that you NEVER WANT TO SEE AGAIN in ANY TRACEBACK
    reported by Failure.

@type f: function

@return: f
)_inlineCallbacksExtraneousappend__code__)rw   s   &r   _extraneousr      s     %%ajj1Hr   c                     ] tR t^tRt^ tRtR&R lt]R 4       t	]	P                  R 4       t	]! ]! R^^
^ 4      4      R 4       t]P                  R 4       t]R	 4       t]P                  R
 4       tR t]R R l4       tR tR tR R lt]R 4       tR R ltR R ltR tR tR tR tR tR R ltR R ltR'R  R! llt R(R" lt!R)R# lt"R)R$ lt#R%t$R# )*Failurea  
A basic abstraction for an error that has occurred.

This is necessary because Python's built-in error mechanisms are
inconvenient for asynchronous communication.

The C{frame} attribute contain the traceback frames.  Each frame is a tuple
of (funcName, fileName, lineNumber, localsItems, globalsItems), where
localsItems and globalsItems are the contents of
C{locals().items()}/C{globals().items()} for that frame, or an empty tuple
if those details were not captured.

Local/global variables in C{frame} will only be captured if
C{captureVars=True} when constructing the L{Failure}.

@ivar value: The exception instance responsible for this failure.

@ivar type: The exception's class.

@ivar stack: Deprecated, always an empty list.  Equivalent information can
    be extracted from C{import traceback;
    traceback.extract_stack(your_failure.tb)}

@ivar frames: list of frames, innermost first.
Nc                   \         ^,           s \         V n         R;V n        ;V n        pW@n        Vf=   \        P
                  ! 4       w  V n        V n        pV P                  f   \        4       hMOVf@   \        V\        4      '       d   VP                  V n        M\        V4      V n        Wn        MW n        Wn        \        V P                  \        4      '       d   V P                  V P                  4       R# Vf?   V'       d   TpM3\        V P                  RR4      '       d   V P                  P                  pWPn        R# )a  
Initialize me with an explanation of the error.

By default, this will use the current C{exception}
(L{sys.exc_info}()).  However, if you want to specify a
particular kind of failure, you can pass an exception as an
argument.

If no C{exc_value} is passed, then an "original" C{Failure} will
be searched for. If the current exception handler that this
C{Failure} is being constructed in is handling an exception
raised by L{raiseException}, then this C{Failure} will act like
the original C{Failure}.

For C{exc_tb} only L{traceback} instances or L{None} are allowed.
If L{None} is supplied for C{exc_value}, the value of C{exc_tb} is
ignored, otherwise if C{exc_tb} is L{None}, it will be found from
execution context (ie, L{sys.exc_info}).

@param captureVars: if set, capture locals and globals of stack
    frames.  This is pretty slow, and makes no difference unless you
    are going to use L{printDetailedTraceback}.
N__traceback__)counttypevaluecaptureVarssysexc_infor2   
isinstance	Exception	__class__r   _extrapolategetattrr   r=   )rG   	exc_valueexc_typeexc_tbr   r=   s   &&&&& r   rI   Failure.__init__   s    2 	
&**	*DJ&(+%DItz2yy -// !)Y//%//	 !O	"J I"Jdjj'**djj):_d;;ZZ--r   c                	   \        V R 4      '       d   V P                  # . ;qn        V P                  pVEe   VP                  pV P                  '       d   VP
                  P                  4       pVP
                  VP                  J d   / pMVP                  P                  4       pWT3 F  pRV9   g   K  VR K  	  \        VP                  4       4      p\        VP                  4       4      pMR;rEVP                  VP                  P                  VP                  P                  VP                  VV34       VP                  pEK  V# )_frames__builtins__r   )hasattrr   r=   rB   r   rR   rV   rQ   listitemsr}   rO   r`   ra   rD   r9   )rG   r%   r=   rw   r[   r\   ds   &      r   r%   Failure.frames8  s   4##<< ""WWnA*::, Gkk..0G A%*n- ) flln-w}}/#%%MMHH$$HH((LL Br   c                	    Wn         R # N)r   )rG   r%   s   &&r   r%   r   [  s    r   Twistedc                	    . # r   r   rr   s   &r   r;   Failure.stack_  s    	r   c                	    ?R # r   r   )rG   r;   s   &&r   r;   r   c  s    r   c                	   V P                   e   V P                   # \        P                  ! V P                  4      '       dj   \	        V P                  \
        4      '       dJ   \        V P                  4      p\        \        \        P                  V4      4      V n         V P                   # V P                  .V n         V P                   # r   )_parentsinspectisclassr   
issubclassr   r   r   mapr
   qual)rG   parentCss   & r   parentsFailure.parentsg  s    ==$== ??499%%*TYY	*J*Jdii(H W\\8!<=DM }} "YYKDM}}r   c                	    Wn         R # r   )r   )rG   r   s   &&r   r   r   s  s    r   c                P    \         P                   ! VP                  4      V n        R# )z
Extrapolate from one failure into another, copying its stack frames.

@param otherFailure: Another L{Failure}, whose traceback information,
    if any, should be preserved as part of the stack presented by this
    one.
@type otherFailure: L{Failure}
N)rV   __dict__)rG   otherFailures   &&r   r   Failure._extrapolatew  s     		,"7"78r   c                    V ^8  d   QhRRRR/# )rv   r   BaseExceptionrx   r   r   )ry   s   "r   rz   Failure.__annotate__  s       7 r   c                    \         P                  \         4      p\        ^,          sRVn        \        Vn        Wn        V P
                  Vn        RVn        V# )z
Create a L{Failure} for an exception without a traceback.

By restricting the inputs significantly, this constructor runs much
faster.
FN)r   __new__r   r   r   r   r   r=   )r   results   & r   _withoutTracebackFailure._withoutTraceback  sF     )
"oo	r   c                V    V P                   ! V!  pV'       g   V P                  4        V# )a  
Trap this failure if its type is in a predetermined list.

This allows you to trap a Failure in an error callback.  It will be
automatically re-raised if it is not a type that you expect.

The reason for having this particular API is because it's very useful
in Deferred errback chains::

    def _ebFoo(self, failure):
        r = failure.trap(Spam, Eggs)
        print('The Failure is due to either Spam or Eggs!')
        if r == Spam:
            print('Spam did it!')
        elif r == Eggs:
            print('Eggs did it!')

If the failure is not a Spam or an Eggs, then the Failure will be
'passed on' to the next errback. In Python 2 the Failure will be
raised; in Python 3 the underlying exception will be re-raised.

@type errorTypes: L{Exception}
)checkraiseException)rG   
errorTypeserrors   &* r   trapFailure.trap  s&    0 

J'!r   c                    V Fa  pTp\         P                  ! V4      '       d-   \        V\        4      '       d   \        P
                  ! V4      pW0P                  9   g   K_  Vu # 	  R# )z
Check if this failure's type is in a predetermined list.

@type errorTypes: list of L{Exception} classes or
                  fully-qualified class names.
@returns: the matching L{Exception} type, or None if no match.
N)r   r   r   r   r
   r   r   )rG   r   r   errs   &*  r   r   Failure.check  sP      ECu%%*UI*F*Fll5)ll"   r   c                   V ^8  d   QhRR/# )rv   rx   r   r   )ry   s   "r   rz   r     s     1 1 1r   c                L    V P                   P                  V P                  4      h)zN
raise the original exception, preserving traceback
information if available.
)r   with_tracebackr=   rr   s   &r   r   Failure.raiseException  s    
 jj''00r   c                j    VP                  V P                  P                  V P                  4      4      # )a  
Throw the original exception into the given generator,
preserving traceback information if available.

@return: The next value yielded from the generator.
@raise StopIteration: If there are no more values in the generator.
@raise anything else: Anything that the generator raises.
)throwr   r   r=   )rG   gs   &&r   throwExceptionIntoGenerator#Failure.throwExceptionIntoGenerator  s&     wwtzz009::r   c                   V ^8  d   QhRR/# rv   rx   strr   )ry   s   "r   rz   r     s     
 
# 
r   c                	    R P                  \        P                  ! V P                  4      \        P                  ! V P                  4      V P                  4       4      # )z<{} {}: {}>)ry   r
   r   r   r   getErrorMessagerr   s   &r   __repr__Failure.__repr__  sA    ##LL(LL#  "
 	
r   c                   V ^8  d   QhRR/# r   r   )ry   s   "r   rz   r     s     C C Cr   c                	0    R V P                  4       ,          # )z[Failure instance: %s])getBriefTracebackrr   s   &r   __str__Failure.__str__  s    '$*@*@*BBBr   c                	    R V9   d   VP                  R 4       VP                  R4      VR&   VP                  R4      VR&   V P                  P                  V4       R# )r;   r   r   r%   r   N)popr   updaterG   states   &&r   __setstate__Failure.__setstate__  sN    eIIg!IIi0j 99X.iU#r   c                   V P                   pV P                  P                  4       pVP                  R4      VR&   . VR&   RV9   d   VP                  R4       V P                  '       d[   V P
                   Uu. uF?  pV^ ,          V^,          V^,          \        V^,          4      \        V^,          4      .NKA  	  upVR&   MV P
                  VR&   RVR&   ^VR&   V# u upi )	z
Avoid pickling objects in the traceback.

This is not called direclty by pickle, since C{BaseException}
implements reduce; instead, pickle calls C{Failure.__reduce__} which
then calls this API.
r   r   r;   r   r%   Nr=   pickled)r   r   rV   r   r   r%   _safeReprVars)rG   _cvs   &   r   __getstate__Failure.__getstate__  s     LLMM  uuZ()'
>EE) 	 %A aDaDaD!!A$'!!A$' %	AhK ++AhK $)#	s   8ACc                	`    \        \        P                  \        4      RV P                  4       3# )Nr   )r   r   r   r   rr   s   &r   
__reduce__Failure.__reduce__  s%     12t7H7H7JKKr   c                    V P                  4       pVP                  R4      VR&   Wn        \        V P                  RR4      '       d   RV P                  n        R# R# )z
Remove references to other objects, replacing them with strings.

On Python 3, this will also set the C{__traceback__} attribute of the
exception instance to L{None}.
r%   r   r   N)r   r   r   r   r   r   r   s   & r   cleanFailureFailure.cleanFailure  sN     !!# 99X.i4::55'+DJJ$ 6r   c                    V P                   e   V P                   # \        V P                  4      ^ 8  d   \        V P                  4      # R# )aY  
Get an object that represents this Failure's stack that can be passed
to traceback.extract_tb.

If the original traceback object is still present, return that. If this
traceback object has been lost but we still have the information,
return a fake traceback object (see L{_Traceback}). If there is no
traceback information at all, return None.
N)r=   r6   r%   r?   rr   s   &r   getTracebackObjectFailure.getTracebackObject!  s:     7777N!dkk**r   c                   V ^8  d   QhRR/# r   r   )ry   s   "r   rz   r   2  s     , , ,r   c                    \        V P                  \        4      '       d   V P                  P                  4       # \        P
                  ! V P                  4      # )z:
Get a string of the exception which caused this Failure.
)r   r   r   r   r
   safe_strrr   s   &r   r   Failure.getErrorMessage2  s=     djj'**::--//

++r   c                   V ^8  d   QhRR/# r   r   )ry   s   "r   rz   r   :  s      3 r   c                	Z    \        4       pV P                  VR 7       VP                  4       # ))file)r   printBriefTracebackgetvalue)rG   ios   & r   r   Failure.getBriefTraceback:  s&    Z  b ){{}r   c               $    V ^8  d   QhRRRRRR/# )rv   elideFrameworkCodeintr'   r   rx   r   )ry   s   "r   rz   r   ?  s"      s  TW r   c                	\    \        4       pV P                  W1VR 7       VP                  4       # ))r   r   r'   )r   printTracebackr   )rG   r   r'   r   s   &&& r   getTracebackFailure.getTraceback?  s/    Z6 	 	
 {{}r   c           	        Vf   ^ RI Hp VP                  pVP                  pVR8X  d   V P                  '       g   RpMTpVR8X  d;   T! RV P
                  V P                  ;'       d    R;'       g    R3,          4       MwVR8X  di   V P                  '       d   R	pMR
pV! V: R\        P                  ! V P                  4      : R\        P                  ! V P                  4      : R24       MV! R4       V P                  '       d   \        V P                  WV4       MVR8X  g	   V! R4       VR8X  gK   V! \        P                  ! V P                  4       R\        P                  ! V P                  4       R24       \        V P                  \        4      '       d.   VP                  R4       V P                  P!                  WV4       VR8X  d   V! RV P
                  ,          4       R# R# )aT  
Emulate Python's standard error reporting mechanism.

@param file: If specified, a file-like object to which to write the
    traceback.

@param elideFrameworkCode: Deprecated, ignored.

@param detail: A string indicating how much information to include
    in the traceback.  Must be one of C{'brief'}, C{'default'}, or
    C{'verbose'}.
N)logr   r   z*--- Failure #%d%s---
z (pickled)  r   	Tracebackz"Traceback (failure with no frames)z: r   z#Traceback (most recent call last):
z	Failure: z (chained Failure)
z*--- End of Failure #%d ---
)twisted.pythonr  logerrr&   r   r   r   r%   r
   r   r   r   r0   r   r   r   r   )rG   r   r   r'   r  r(   formatDetail	hasFramess   &&&&    r   r   Failure.printTracebackF  s    <*::DJJYt'7'7'7 7L!L Y):: > >FF3GH w{{{'	@	g..tyy97;K;KDJJ;WY
 45 ;;;$++q77"kN  dii()G,<,<TZZ,H+ILM djj'**JJ-.JJ%%dGY-

:; r   c                ,    V P                  WRR7       R# )z+
Print a traceback as densely as possible.
r   r'   Nr   rG   r   r   s   &&&r   r   Failure.printBriefTraceback  s     	DWEr   c                ,    V P                  WRR7       R# )zA
Print a traceback with detailed locals and globals information.
r   r  Nr  r  s   &&&r   printDetailedTracebackFailure.printDetailedTraceback  s     	DYGr   )r   r   r   r   r   r=   r   r   )NNNF)    r   )NFr   )Nr  )%r   r   r   r   r3   r   r   rI   propertyr%   setterr   r	   r;   r   r   staticmethodr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r   r   r   r      s7   4 GH7r    D ]]  	2r156 7 \\  	 	 ^^   
9  ": 1 	; 	;
C$&PL
,",
?<BFH Hr   r   c                f    V  UUu. uF  w  rV\         P                  ! V4      3NK  	  upp# u uppi )aU  
Convert a list of (name, object) pairs into (name, repr) pairs.

L{twisted.python.reflect.safe_repr} is used to generate the repr, so no
exceptions will be raised by faulty C{__repr__} methods.

@param varsDictItems: a sequence of (name, value) pairs as returned by e.g.
    C{locals().items()}.
@returns: a sequence of (name, repr) pairs.
)r
   	safe_repr)varsDictItemsr.   objs   &  r   r   r     s/     ?LLm{T7$$S)*mLLLs   #-TFc                V   WV3R8X  d   \         P                  ! 4       pV^ ,          V P                  8X  gV   \        '       dJ    \	        V^,          4      p\        RP                  V4      4       ^ RIpVP                  V^,          4       V! WW#V4       R#   \
         d    Rp LQi ; i)z3
Initialize failure object, possibly spawning pdb.
Nz
broken strz8Jumping into debugger for post-mortem of exception '{}':)NNN)
r   r   r   DO_POST_MORTEMr   r   printry   pdbpost_mortem)	rG   r   r   r   r   Failure__init__excstrreprr  s	   &&&&&&   r   
_debuginitr"    s     	V$(::lln1v'NN'c!f+ JQQ
 OOCF#DX{C ! '&'s   B B('B(c                 $    \         \        n        R# )z"
Enable debug hooks for Failures.
N)r"  r   rI   r   r   r   startDebugModer$    s     "Gr   )r   )-r3   
__future__r   rU   rV   r   r!   r   	functoolsr   r   r   r   typingr   r   r   incrementalr	   r  r
   twisted.python.deprecater   objectr   r   traceupLengthr   r   r0   EXCEPTION_CAUGHT_HEREr2   r?   r8   r7   rN   r|   r   r   r   r   r  rI   r"  r$  r   r   r   <module>r-     s    #     
    . .  " 7m8CK+@A		y 	+/^ : i B   8+ +<    pHm pHfM  
 $$D:"r   