Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/twisted/python/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/twisted/python/__pycache__/failure.cpython-310.pyc
o

�bi�@sdZddlZddlZddlZddlZddlmZddlmZddlZddl	m
Z
dadZGdd�de
�Zd#d
d�ZdZGd
d�de
�Zdd�ZGdd�d�ZGdd�d�ZGdd�d�ZgZdd�ZGdd�de�Zdd�ZdZddddejfdd �Zd!d"�ZdS)$z9
Asynchronous-friendly error mechanism.

See L{Failure}.
�N)�getmro)�StringIO)�reflect�c@seZdZdS)�DefaultExceptionN)�__name__�
__module__�__qualname__�r
r
�8/usr/lib/python3/dist-packages/twisted/python/failure.pyrsr�defaultc	Csx|dvrtd|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��q�qwdSdS)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�brief�verbose�verbose-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
rz%s:%d: %s(...)
zA [Capture of Locals and Globals disabled (use captureVars=True)]
rz [ Locals ]
z  z : z
 ( Globals )
N)�
ValueError�	linecache�getline�strip�repr)�frames�write�detail�w�method�filename�lineno�	localVars�
globalVars�name�valr
r
r�
format_frames#s@������r"z--- <exception caught here> ---c@seZdZdZdS)�NoCurrentExceptionErrorz�
    Raised when trying to create a Failure from the current interpreter
    exception state and there is no current exception state.
    N)rrr	�__doc__r
r
r
rr#Vsr#cCsvt|�dks
Jd��d}|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), ...]
    rzMust pass some framesN�)�len�_Frame�_TracebackFrame�tb_next)�stackFrames�tbFrames�stack�sf�firstTb�tbr
r
r�
_Traceback]s


r0c@�eZdZdZdd�ZdS)r(zq
    Fake traceback object which can be passed to functions in the standard
    library L{traceback} module.
    cCs||_|j|_d|_dS)z-
        @param frame: _Frame object
        N)�tb_frame�f_lineno�	tb_linenor))�self�framer
r
r�__init__�s
z_TracebackFrame.__init__N�rrr	r$r7r
r
r
rr(�sr(c@r1)r'aD
    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)
    cCs6|\}}}}}t||�|_||_i|_i|_||_dS)z�
        @param frameinfo: (methodname, filename, lineno, locals, globals)
        @param back: previous (older) stack frame
        @type back: C{frame}
        N)�_Code�f_coder3�	f_globals�f_locals�f_back)r5�	frameinfo�backr rr�localz�globalzr
r
rr7�s
z_Frame.__init__Nr8r
r
r
rr'�s
r'c@r1)r9zB
    A fake code object, used by L{_Traceback} via L{_Frame}.
    cCs||_||_dS)N)�co_name�co_filename)r5r rr
r
rr7�s
z_Code.__init__Nr8r
r
r
rr9�sr9cCst�|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
    )�_inlineCallbacksExtraneous�append�__code__)�fr
r
r�_extraneous�srHc@s�eZdZdZdZdZejdZd.dd�Z	dd	�Z
d
d�Zdd
�Zdd�Z
edd��Zedd��Zdefdd�Zdefdd�Zdd�Zdd�Zdd�Zdefdd �Zdefd!d"�Zd/d$ed%edefd&d'�Zd0d(d)�Zd1d*d+�Zd1d,d-�ZdS)2�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{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.
    rN�YIELD_VALUEFcCstdat|_d|_|_}||_t|t�r|durtd��d}|dur)|��}|durAt�	�\|_|_}|jdur>t
��d}n|durXt|t�rO|j|_nt|�|_||_n||_||_t|jt
�rl|�|j�dSt|jd�r~|�|jj�|j`dS|dur�|r�|}nt|jdd�r�|jj}g}|_g}|_||_|r�|j}	n
t|jt
�s�d}	}|r�|	r�|	j}	|d8}|r�|	s�|	�r|r�|	j��}
|	j|	jur�i}n|	j��}||
fD]	}d|vr�|d=q�|
��}
|��}nd}
}|�d|	jj|	jj|	j |
|f�|	j}	|	s�|du�r]|j}	|�rB|	j��}
|	j|	ju�r i}n|	j��}||
fD]}d|v�r3|d=�q)t!|
���}
t!|���}nd}
}|�"|	jj|	jj|j#|
|f�|j$}|du�st%�&|j��r{t'|jt��r{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
)-�count�type�value�captureVars�
isinstance�str�	TypeError�_findFailure�sys�exc_infor#�	Exception�	__class__rI�_extrapolate�hasattrrK�getattrrLrr,r/r2r=r<�copyr;�items�insertr:rBrCr3�listrEr4r)�inspect�isclass�
issubclassr�mapr�qual�parents)r5�	exc_value�exc_type�exc_tbrQr/�stackOffsetrr,rGr@rA�d�parentCsr
r
rr7�s�





�

�
��
�



���	
�
zFailure.__init__cCszt�|j�|_t��\}}}g}|dur2|j}|jtvr+|�|jj|jj	|j
ddf�|j}|dus|�|j
�||_
dS)a,
        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}
        Nr
)r]�__dict__rVrWr2r:rDrErBrCr4r)�extendr)r5�otherFailure�_r/rrGr
r
rrZ�s

��
zFailure._extrapolatecGs|j|�}|s|��|S)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)r5�
errorTypes�errorr
r
r�trap�s
zFailure.trapcGsB|D]}|}t�|�rt|t�rt�|�}||jvr|SqdS)a
        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)rarbrcrXrrerf)r5rsrt�errr
r
rrq�s

�z
Failure.checkcCs|j�|j��)zf
        raise the original exception, preserving traceback
        information if available.
        )rP�with_tracebackr/�r5r
r
rrr�szFailure.raiseExceptioncCs|�|j|j|j�S)aJ
        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.
        )�throwrOrPr/)r5�gr
r
r�throwExceptionIntoGenerator�sz#Failure.throwExceptionIntoGeneratorcCs�t��d}|s
dSd}|}|jr|}|j}|js|j}|j|jjur)|j�d�S|jj	r7|jj	|j
|jkr9dS|rK|j}|j|jjurK|j�d�S|jj
}|r^|j|jjur`|j�d�SdSdS)zV
        Find the failure that represents the exception currently in context.
        ���Nr5)rVrWr)r2r:rrrFr<�get�co_code�tb_lasti�_yieldOpcoder{r=)�clsr/�secondLastTb�lastTb�	lastFramer6r
r
rrU�s4�	���zFailure._findFailure�returncCs"d�t�|j�t�|j�|���S)Nz<{} {}: {}>)�formatrrerYrO�getErrorMessagerxr
r
r�__repr__&s


�zFailure.__repr__cCsd|��S)Nz[Failure instance: %s])�getBriefTracebackrxr
r
r�__str__-szFailure.__str__cCs\|jr|jS|j��}dd�|jD�|d<d|d<|jdur(dd�|jD�|d<d|d	<|S)
z(Avoid pickling objects in the traceback.c	S�6g|]}|d|d|dt|d�t|d�g�qS�rr%��r��
_safeReprVars��.0�vr
r
r�
<listcomp>6��

��z(Failure.__getstate__.<locals>.<listcomp>rNr/c	Sr�r�r�r�r
r
rr�Gr�r,r%�pickled)r�rmr]rr,)r5�cr
r
r�__getstate__0s

�

�zFailure.__getstate__cCs(|��|_t|jdd�rd|j_dSdS)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}.
        rLN)r�rmr\rPrLrxr
r
r�cleanFailureUs
�zFailure.cleanFailurecCs0|jdur|jSt|j�dkrt|j|j�SdS)a�
        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.
        Nr)r/r&rr0r,rxr
r
r�getTracebackObjectas


zFailure.getTracebackObjectcCs"t|jt�r|j��St�|j�S)zJ
        Get a string of the exception which caused this Failure.
        )rRrPrIr�r�safe_strrxr
r
rr�rs
zFailure.getErrorMessagecCst�}|j|d�|��S)N)�file)r�printBriefTraceback�getvalue)r5�ior
r
rr�zszFailure.getBriefTracebackr�elideFrameworkCodercCst�}|j|||d�|��S)N)r�r�r)r�printTracebackr�)r5r�rr�r
r
r�getTracebacks
�zFailure.getTracebackcCsb|dur
ddlm}|j}|j}|dkr|jsd}n|}|dkr/|d|j|jr)dp*df�n"|d	krM|jr9d
}nd}|d|t�	|j
�t�	|j�f�n|d
�|jrq|sit|j
td�||�|t�d��t|j||�n|d	ksy|d�|d	ks�|t�|j
��dt�	|j��d��t|jt�r�|�d�|j�|||�|dkr�|d|j�dSdS)a
        Emulate Python's standard error reporting mechanism.

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

        @param elideFrameworkCode: A flag indicating whether to attempt to
            remove uninteresting frames from within Twisted itself from the
            output.

        @param detail: A string indicating how much information to include
            in the traceback.  Must be one of C{'brief'}, C{'default'}, or
            C{'verbose'}.
        Nr)�logrrz*--- Failure #%d%s---
z (pickled) � r
�	Tracebackz"Traceback (failure with no frames)z%s: %s: %s
z#Traceback (most recent call last):
rz	Failure: z: z (chained Failure)
z*--- End of Failure #%d ---
)�twisted.pythonr��logerrrrQrNr�rrr�rOrPr"r,�
traceupLength�EXCEPTION_CAUGHT_HERErerRrIr�)r5r�r�rr�r�formatDetail�	hasFramesr
r
rr��sL����$
�zFailure.printTracebackcC�|j||dd�dS)z;
        Print a traceback as densely as possible.
        r
�rN�r��r5r�r�r
r
rr���zFailure.printBriefTracebackcCr�)zQ
        Print a traceback with detailed locals and globals information.
        rr�Nr�r�r
r
r�printDetailedTraceback�r�zFailure.printDetailedTraceback)NNNF)rr)NFr)Nr)rrr	r$r�r,�opcode�opmapr�r7rZrurqrrrHr{�classmethodrUrSr�r�r�r�r�r�r��intr�r�r�r�r
r
r
rrI�s4

'

:%

ErIcCsdd�|D�S)aq
    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.
    cSsg|]\}}|t�|�f�qSr
)r�	safe_repr)r�r �objr
r
rr��sz!_safeReprVars.<locals>.<listcomp>r
)�
varsDictItemsr
r
rr��sr�TFc	Cs�|||fdkr:t��}|d|jks:tr:zt|d�}Wnty'd}Ynwtd�|��ddl}|�	|d�||||||�dS)z;
    Initialize failure object, possibly spawning pdb.
    )NNNrr%z
broken strz8Jumping into debugger for post-mortem of exception '{}':Nr�)
rVrWrY�DO_POST_MORTEMrS�
BaseException�printr��pdb�post_mortem)	r5rgrhrirQ�Failure__init__�exc�strreprr�r
r
r�
_debuginit�s ���r�cCs
tt_dS)z*
    Enable debug hooks for Failures.
    N)r�rIr7r
r
r
r�startDebugModes
r�)r)r$r]rarrVrr�rr�r�rrNr�rXrr"r�r#r0r(r'r9rDrHr�rIr�r�r7r�r�r
r
r
r�<module>sF
0&

�

Spamworldpro Mini