%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/python/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/python/__pycache__/failure.cpython-312.pyc

�

Ϫ�f�m��p�dZddlZddlZddlZddlZddlZddlmZddlmZddl	m
Z
mZmZddl
Z
ddlmZede
def�	�Zdad
ZGd�de�Zd"d
�ZdZGd�de�Zd�ZGd�d�ZGd�d�ZGd�d�ZgZdedefd�ZGd�de�Z d�Z!dZ"dddde jFfd �Z$d!�Z%y)#z9
Asynchronous-friendly error mechanism.

See L{Failure}.
�N)�getmro)�StringIO)�Callable�NoReturn�TypeVar)�reflect�_T_Callable.)�bound�c��eZdZy)�DefaultExceptionN)�__name__�
__module__�__qualname__���8/usr/lib/python3/dist-packages/twisted/python/failure.pyr
r
#s��rr
c
�V�|dvrtd|�d���|}|dk(r|D]\}}}}}||�d|�d|�d���y|dk(rM|D]G\}}}}}|d|�d	|�d
|�d��|dtj||�j�z��Iy|dk(r$|D]\}}}}}|d
|||fz��|d�y|dk(rp|D]j\}}}}}|d
|||fz�|d�|D]\}	}
|d|	�dt	|
��d���|d�|D]\}	}
|d|	�dt	|
��d����lyy)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 �)r�:�
rz  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�vals           r�
format_framesr,'s���"�Q�Q��5;�
>�
�	
�	�A�
���?E�	1�;�F�H�f�i��
��
�!�F�8�1�V�H�B�/�0�	1�	�9�	�?E�	H�;�F�H�f�i��
���
�(�6�(�%��x�r�B�C�
�j�9�,�,�X�v�>�D�D�F�F�G�	H�
�.�	.�?E�	?�;�F�H�f�i��
� �H�f�f�#=�=�>�	?�	�
N�O�	�9�	�?E�	/�;�F�H�f�i��
� �H�f�f�#=�=�>�
�o��&�
/�	��c��B�t�f�C��S�	�{�"�-�.�
/�
���'�
/�	��c��B�t�f�C��S�	�{�"�-�.�
/�	/�
rz--- <exception caught here> ---c��eZdZdZy)�NoCurrentExceptionErrorz�
    Raised when trying to create a Failure from the current interpreter
    exception state and there is no current exception state.
    N)rrr�__doc__rrrr.r.Zs��rr.c��t|�dkDsJd��d}|D]}t||�}�t|d|�}t|�x}}|ddD]*}t||�}t|�|_|j}�,|S)a5
    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 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�tbs      r�
_Tracebackr<as����x�=�1��5�5�5��
�E��"���r�5�!��"�
�8�A�;��&�E�"�5�)�)�G�b��q�r�l����r�5�!��$�U�+��
�
�Z�Z����Nrc��eZdZdZd�Zy)r4zq
    Fake traceback object which can be passed to functions in the standard
    library L{traceback} module.
    c�d�||_|j|_|j|_d|_y)z-
        @param frame: _Frame object
        N)�tb_frame�f_lineno�	tb_lineno�f_lasti�tb_lastir5)�self�frames  r�__init__z_TracebackFrame.__init__�s(����
�������
�
��
���rN�rrrr/rFrrrr4r4�s���
rr4c��eZdZdZd�Zy)r3aD
    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��|\}}}}}t||�|_||_t|xsi�|_t|xsi�|_||_d|_tt�j�|_d|_y)z�
        @param frameinfo: (methodname, filename, lineno, locals, globals)
        @param back: previous (older) stack frame
        @type back: C{frame}
        rN)
�_Code�f_coder@�dict�	f_globals�f_locals�f_backrB�vars�builtins�copy�
f_builtins�f_trace)rD�	frameinfo�backr*r&r'�localz�globalzs        rrFz_Frame.__init__�sr��3<�/��h�����D�(�+�����
��g�m��,����V�\�r�*��
��������x�.�-�-�/�����rNrGrrrr3r3�s���rr3c��eZdZdZd�Zd�Zy)rJz�
    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���||_||_d|_d|_d|_g|_d|_d|_d|_d|_	d|_
d|_d|_d|_
d|_d|_y)Nrrr)�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)rDr*r&s   rrFz_Code.__init__�s{�����#��������������������������
����"#���!"�����
������rc��y)N))NNNNr�rDs r�co_positionsz_Code.co_positions�s��*rN)rrrr/rFrmrrrrJrJ�s����$+rrJ�f�returnc�D�tj|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__)rns r�_extraneousrt�s���%�%�a�j�j�1��Hrc���eZdZdZdZdZejdZdd�Z	d�Z
d�Zd�Zd	e
fd
�Zed��Zed��Zd	efd
�Zd	efd�Zd�Zd�Zd�Zd	efd�Zd	efd�Zddeded	efd�Zdd�Zdd�Zdd�Zy)�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_VALUEc��tdzat|_dx|_x|_}||_t	|t
�r
|�t
d��d}|�|j�}|�;tj�\|_|_}|j�
t��d}nJ|�:t	|t�r|j|_nt|�|_||_n||_||_t	|jt�r|j|j�yt|jd�r2|j|jj �|j`y|�2|r|}n-t#|jdd�r|jj$}gx}|_gx}|_||_|r
|j,}	nt	|jt�sdx}	}|r	r|	j.}	|dz}|r|	r�	r�|r�|	j0j3�}
|	j0|	j4uri}n|	j4j3�}||
fD]
}d|vs�|d=�|
j7�}
|j7�}ndx}
}|j9d|	j:j<|	j:j>|	j@|
|f�|	j.}	|	r��|��|j,}	|r�|	j0j3�}
|	j0|	j4uri}n|	j4j3�}||
fD]
}d|vs�|d=�tC|
j7��}
tC|j7��}ndx}
}|jE|	j:j<|	j:j>|jF|
|f�|jH}|���tKjL|j�rXtO|jt�r>tQ|j�}
tCtStTjV|
��|_,y|jg|_,y)	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}.
        r1Nz$Strings are not supported by Failurer�__failure__�
__traceback__�__builtins__r)-�count�type�value�captureVars�
isinstance�str�	TypeError�_findFailure�sys�exc_infor.�	Exception�	__class__rv�_extrapolate�hasattrry�getattrrzr!r8r;r?rOrNrRrM�items�insertrKr[r\r@�listrrrAr5�inspect�isclass�
issubclassr�mapr�qual�parents)rD�	exc_value�exc_type�exc_tbrr;�stackOffsetr!r8rnrWrX�d�parentCss              rrFzFailure.__init__s���2��	����
�&*�*��	�*�D�J��&����i��%�(�*:��B�C�C������)�)�+�I���(+����%�D�I�t�z�2��y�y� �-�/�/��K�
�
��)�Y�/�%�/�/��	�!��O��	�"�D�J� �D�I�"�D�J��d�j�j�'�*����d�j�j�)���4�:�:�}�-�
���d�j�j�4�4�5��
�
�&��
�:��������_�d�;��Z�Z�-�-��!�!��������
�
���
����A��D�J�J��0�#�"�A���a����A��1��K�	�a��������*���:�:����,� �G��k�k�.�.�0�G� �&��.�A�%��*��n�-�.� �����!�-�-�/��#%�%����L�L���H�H�$�$��H�H�(�(��J�J����	
����A�1�4�n����A�������*���:�:����,� �G��k�k�.�.�0�G� �&��.�A�%��*��n�-�.��f�l�l�n�-���w�}�}��/��#%�%����M�M��H�H�$�$��H�H�(�(��L�L����
����B�1�n�2�?�?�4�9�9�%�*�T�Y�Y�	�*J��d�i�i�(�H���G�L�L�(� ;�<�D�L� �I�I�;�D�Lrc��tj|j�|_tj�\}}}g}|�u|j}|j
tvrH|j|j
j|j
j|jddf�|j}|��u|j|j�||_
y)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)rR�__dict__r�r�r?rKrqrrr[r\rAr5�extendr!)rD�otherFailure�_r;r!rns      rr�zFailure._extrapolate�s����	�	�,�"7�"7�8��
��<�<�>���1�b����n����A��x�x�9�9��
�
��X�X�%�%�q�x�x�';�';�R�\�\�2�r�R�����B�
�n�	�
�
�d�k�k�"���rc�H�|j|�}|s|j�|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)rD�
errorTypes�errors   r�trapzFailure.trap�s(��0��
�
�J�'������!��rc��|D]P}|}tj|�r%t|t�rt	j
|�}||jvs�N|cSy)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)r�r�r�r�rr�r�)rDr�r��errs    rr�z
Failure.check�sQ�� �	�E��C����u�%�*�U�I�*F��l�l�5�)���d�l�l�"���	�rroc�L�|jj|j��)zf
        raise the original exception, preserving traceback
        information if available.
        )r~�with_tracebackr;rls rr�zFailure.raiseException�s��
�j�j�'�'����0�0rc�j�|j|jj|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.
        )�throwr~r�r;)rD�gs  r�throwExceptionIntoGeneratorz#Failure.throwExceptionIntoGenerator�s&���w�w�t�z�z�0�0����9�:�:rc���tj�d}|syd}|}|jr|}|j}|jr�|j}|j|j
jur|jjd�S|jjr0|jj|j|jk7ry|rI|j}|j|jjur|jjd�S|jj}|r>|j|jjur|jjd�Syy)zV
        Find the failure that represents the exception currently in context.
        ���NrD)r�r�r5r?rKr�rsrN�getrarC�_yieldOpcoder�rO)�clsr;�secondLastTb�lastTb�	lastFramerEs      rr�zFailure._findFailure	sC��
�\�\�^�B�
���������n�n�!�L��^�^�F��n�n��O�O�	����s�1�1�:�:�:��%�%�)�)�&�1�1�� � �(�(�Y�-=�-=�-E�-E��O�O�.
�
�
�
�.�
�
� �)�)�E��|�|�s�>�>�G�G�G��~�~�)�)�&�1�1����"�"���U�\�\�S�%D�%D�%M�%M�M��>�>�%�%�f�-�-�N�5rc��djtj|j�tj|j�|j��S)Nz<{} {}: {}>)�formatrr�r�r}�getErrorMessagerls r�__repr__zFailure.__repr__DsA���#�#��L�L����(��L�L����#�� � �"�
�	
rc�(�d|j�zS)Nz[Failure instance: %s])�getBriefTracebackrls r�__str__zFailure.__str__Ks��'�$�*@�*@�*B�B�Brc��|jr|jS|jj�}|jD�cgc]*}|d|d|dt	|d�t	|d�g��,c}|d<d|d<|j
�C|j
D�cgc]*}|d|d|dt	|d�t	|d�g��,c}|d	<d|d
<|Scc}wcc}w)z(Avoid pickling objects in the traceback.rr1��rr!Nr;r8�pickled)r�r�rRr!�
_safeReprVarsr8)rD�c�vs   r�__getstate__zFailure.__getstate__Ns����<�<��=�=� ��M�M��� ���[�[�	
��
�!���!���!���a��d�#��a��d�#�
�	
��(����$���:�:�!����	��
�a�D��a�D��a�D�!�!�A�$�'�!�!�A�$�'��	�A�g�J���)�����;	
��"	s�/C�/Cc��|j�|_t|jdd�rd|j_yy)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}.
        rzN)r�r�r�r~rzrls r�cleanFailurezFailure.cleanFailuress5���)�)�+��
��4�:�:���5�'+�D�J�J�$�6rc��|j�|jSt|j�dkDr t|j|j�Sy)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;r2r!r<r8rls r�getTracebackObjectzFailure.getTracebackObjects@���7�7���7�7�N�
����
��
!��d�j�j�$�+�+�6�6�rc��t|jt�r|jj�St	j
|j�S)zJ
        Get a string of the exception which caused this Failure.
        )r�r~rvr�r�safe_strrls rr�zFailure.getErrorMessage�s:���d�j�j�'�*��:�:�-�-�/�/�����
�
�+�+rc�Z�t�}|j|��|j�S)N)�file)r�printBriefTraceback�getvalue)rD�ios  rr�zFailure.getBriefTraceback�s&��
�Z��� � �b� �)��{�{�}�r�elideFrameworkCoder#c�^�t�}|j|||��|j�S)N)r�r�r#)r�printTracebackr�)rDr�r#r�s    r�getTracebackzFailure.getTraceback�s2��
�Z������(:�6�	�	
��{�{�}�rc	���|�ddlm}|j}|j}|dk(r|jsd}n|}|dk(r*|d|j
|jxrdxsdfz�nj|d	k(r]|jrd
}nd}||�dtj|j��dtj|j��d
��n|d�|jrH|s.t|jtd||�|t�d
��t|j||�n
|d	k(s|d�|d	k(sH|tj |j��dtj|j��d
��t#|jt$�r.|jd�|jj'|||�|dk(r|d|j
z�yy)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: rz#Traceback (most recent call last):
z	Failure: z (chained Failure)
z*--- End of Failure #%d ---
)�twisted.pythonr��logerrr"rr|r�r!rr�r}r~r,r8�
traceupLength�EXCEPTION_CAUGHT_HEREr�r�rvr�)rDr�r�r#r�r$�formatDetail�	hasFramess        rr�zFailure.printTraceback�s����<�*��:�:�D��J�J���Y��t�'7�'7�7�L�!�L��Y��
�)��:�:���� >��F�3�G�H�
��w�
��{�{�'�	�@�	�
��g�.�.�t�y�y�9�7�;K�;K�D�J�J�;W�Y�
�

�4�5��;�;�%��d�j�j�-���9�1�l�K��*�+�2�.�/��$�+�+�q�,�7��7�"�
�k�N��� �
����d�i�i�(�)��G�,<�,<�T�Z�Z�,H�+I��L�M��d�j�j�'�*��J�J�-�.��J�J�%�%�d�,>��G��Y��
�-��
�
�:�;�rc�,�|j||d��y)z;
        Print a traceback as densely as possible.
        r�r#N�r��rDr�r�s   rr�zFailure.printBriefTraceback�s��	
���D�"4�W��Erc�,�|j||d��y)zQ
        Print a traceback with detailed locals and globals information.
        rr�Nr�r�s   r�printDetailedTracebackzFailure.printDetailedTraceback�s��	
���D�"4�Y��Gr)NNNF)rr)NFr)Nr) rrrr/r�r8�opcode�opmapr�rFr�r�r�rr�rtr��classmethodr�r�r�r�r�r�r�r�r��intr�r�r�r�rrrrvrv�s����$�G��E��<�<�
�.�L�c'�J�:�:� 1��1��;��;��8.��8.�t
�#�
�C��C�#�J
,��",��,��3��
�s����TW��C<�JF�Hrrvc�b�|D��cgc]\}}|tj|�f��c}}Scc}}w)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.
    )r�	safe_repr)�
varsDictItemsr*�objs   rr�r��s-��?L�L�{��c�T�7�$�$�S�)�*�L�L��Ls�!+TFc�(�|||fdk(rmtj�}|d|jk(sGtrA	t	|d�}t
dj|��ddl}|j|d�||||||�y#t
$rd}Y�LwxYw)z;
    Initialize failure object, possibly spawning pdb.
    )NNNrr1z
broken strz8Jumping into debugger for post-mortem of exception '{}':Nr�)
r�r�r��DO_POST_MORTEMr��
BaseException�printr��pdb�post_mortem)	rDr�r�r�r�Failure__init__�exc�strreprr�s	         r�
_debuginitr�	s���	�8�V�$�(:�:��l�l�n���1�v����'�N�
'��c�!�f�+��
�J�Q�Q���
�

��O�O�C��F�#��D�)�X�v�{�C��!�
'�&��
'�s�B�B�Bc�"�tt_y)z*
    Enable debug hooks for Failures.
    N)r�rvrFrrr�startDebugModer�&s��"�G�r)r)&r/rQrRr�rr�rr�r�typingrrrr�r�r�objectr	r|r�r�r
r,r�r.r<r4r3rJrqrtr�rvr�r�rFr�r�rrr�<module>r�s��������
���.�.�
�"��m�8�C��K�+@�A��	���
�	�y�	�+/�`:���i��#�R
�
� ��8+�+�< ��

�;�

�;�

� LH�m�LH�^M� ��
�
����$�$�
D�:"r

Zerion Mini Shell 1.0