File: //lib/python3/dist-packages/twisted/python/__pycache__/failure.cpython-38.pyc
U
�bi � @ s d Z ddlZddlZddlZddlZddlmZ ddlmZ ddlZddl m
Z
dadZG dd� de
�Zd#d
d�ZdZG d
d� de
�Zdd� ZG dd� d�ZG dd� d�ZG dd� d�Zg Zdd� ZG dd� de�Zdd� 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 sv |dkrt d|f ��|}|dkrT| D ](\}}}}}||� d|� d|� d�� q&�n|dkr�| D ]B\}}}}}|d|� d|� d |� d�� |d
t�||��� � q`n�|dkr�| D ] \}}}}}|d|||f � q�|d
� n�|dk�rr| D ]�\}}}}}|d|||f � |d� |D ]$\} }
|d| � dt|
�� d�� �q|d� |D ]$\} }
|d| � dt|
�� d�� �qJq�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 �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
r z%s:%d: %s(...)
zA [Capture of Locals and Globals disabled (use captureVars=True)]
r z [ Locals ]
z z : z
( Globals )
N)�
ValueError� linecache�getline�strip�repr)�frames�write�detail�w�method�filename�linenoZ localVarsZ
globalVars�name�valr
r
r �
format_frames# s6 ��
r z--- <exception caught here> ---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 |�dkstd��d}| D ]}t||�}qt|d |�}t|� }}|dd� D ]}t||�}t|�|_|j}qR|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�AssertionError�_Frame�_TracebackFrame�tb_next)ZstackFramesZtbFrames�stackZsfZfirstTb�tbr
r
r �
_Traceback] s
r+ c @ s e Zd ZdZdd� ZdS )r'