/usr/lib/python3/dist-packages/twisted/python/__pycache__
Edit: /usr/lib/python3/dist-packages/twisted/python/__pycache__/failure.cpython-310.pyc (18960B)
o
bi @ s d Z ddlZddlZddlZddlZddlmZ ddlmZ ddlZddl m
Z
dadZG dd de
Zd#d
dZdZG d
d de
Zdd ZG dd dZG dd dZG dd dZg Zdd ZG dd deZdd ZdZddddejfdd Zd!d" ZdS )$z9
Asynchronous-friendly error mechanism.
See L{Failure}.
N)getmro)StringIO)reflect c @ s e Zd ZdS )DefaultExceptionN)__name__
__module____qualname__ r
r
8/usr/lib/python3/dist-packages/twisted/python/failure.pyr s r defaultc C sx |dvrt d|f |}|dkr*| D ]\}}}}}|| d| d| d qdS |dkrT| D ]!\}}}}}|d| d| d | d |d
t|| q0dS |dkrq| D ]\}}}}}|d|||f qZ|d
dS |dkr| D ]B\}}}}}|d|||f |d |D ]\} }
|d| dt|
d q|d |D ]\} }
|d| dt|
d qqwdS dS )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
)r briefverboseverbose-vars-not-capturedzNDetail must be default, brief, verbose, or verbose-vars-not-captured. (not %r)r
:
r z File "z", line z, in z %s
r z%s:%d: %s(...)
zA [Capture of Locals and Globals disabled (use captureVars=True)]
r z [ Locals ]
z z : z
( Globals )
N)
ValueError linecachegetlinestriprepr)frameswritedetailwmethodfilenamelineno localVars
globalVarsnamevalr
r
r
format_frames# s@ r" z---
---c @ s e Zd ZdZdS )NoCurrentExceptionErrorz
Raised when trying to create a Failure from the current interpreter
exception state and there is no current exception state.
N)r r r __doc__r
r
r
r r# V s r# c C sv t |dks
J dd}| D ]}t||}qt|d |}t| }}|dd D ]}t||}t||_|j}q)|S )a
Construct a fake traceback object using a list of frames. Note that
although frames generally include locals and globals, this information
is not kept by this method, since locals and globals are not used in
standard tracebacks.
@param stackFrames: [(methodname, filename, lineno, locals, globals), ...]
@param tbFrames: [(methodname, filename, lineno, locals, globals), ...]
r zMust pass some framesN )len_Frame_TracebackFrametb_next)stackFramestbFramesstacksffirstTbtbr
r
r
_Traceback] s
r0 c @ e Zd ZdZdd ZdS )r( zq
Fake traceback object which can be passed to functions in the standard
library L{traceback} module.
c C s || _ |j| _d| _dS )z-
@param frame: _Frame object
N)tb_framef_lineno tb_linenor) )selfframer
r
r __init__ s
z_TracebackFrame.__init__Nr r r r$ r7 r
r
r
r r( s r( c @ r1 )r' aD
A fake frame object, used by L{_Traceback}.
@ivar f_code: fake L{code} 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 C s6 |\}}}}}t ||| _|| _i | _i | _|| _dS )z
@param frameinfo: (methodname, filename, lineno, locals, globals)
@param back: previous (older) stack frame
@type back: C{frame}
N)_Codef_coder3 f_globalsf_localsf_back)r5 frameinfobackr r r localzglobalzr
r
r r7 s
z_Frame.__init__Nr8 r
r
r
r r' s
r' c @ r1 )r9 zB
A fake code object, used by L{_Traceback} via L{_Frame}.
c C s || _ || _d S )N)co_nameco_filename)r5 r r r
r
r r7 s
z_Code.__init__Nr8 r
r
r
r r9 s r9 c C s t | j | S )a
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
)_inlineCallbacksExtraneousappend__code__)fr
r
r _extraneous s rH c @ s e Zd ZdZdZdZejd Zd.ddZ dd Z
d
d Zdd
Zdd Z
edd Zedd ZdefddZdefddZdd Zdd Zdd Zdefdd Zdefd!d"Zd/d$ed%edefd&d'Zd0d(d)Zd1d*d+Zd1d,d-ZdS )2Failurea
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{stack} and C{frame} attributes contain 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.
@ivar value: The exception instance responsible for this failure.
@ivar type: The exception's class.
@ivar stack: list of frames, innermost last, excluding C{Failure.__init__}.
@ivar frames: list of frames, innermost first.
r NYIELD_VALUEFc C s t d a t | _ d | _ | _}|| _t|tr|du rtdd}|du r)| }|du rAt \| _| _}| jdu r>t
d}n|du rXt|trO|j| _nt|| _|| _n|| _|| _t| jt
rl| | j dS t| jdr~| | jj | j`dS |du r|r|}nt| jddr| jj}g }| _g }| _|| _|r|j} n
t| jt
sd } }|r| r| j} |d8 }|r| s| r|r| j }
| j| ju ri }n| j }||
fD ] }d|v r|d= q|
}
| }nd }
}|d| jj| jj| j |
|f | j} | s|dur]|j} |rB| j }
| j| ju r i }n| j }||
fD ]}d|v r3|d= q)t!|
}
t!| }nd }
}|"| jj| jj|j#|
|f |j$}|dust%&| jr{t'| jtr{t(| j}
t!t)t*j+|
| _,dS | jg| _,dS ) 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}.
r% Nz$Strings are not supported by Failurer __failure__
__traceback____builtins__r
)-counttypevaluecaptureVars
isinstancestr TypeError_findFailuresysexc_infor# Exception __class__rI _extrapolatehasattrrK getattrrL r r, r/ r2 r= r<