�
Ϫ�f�m � �p � d Z ddlZddlZddlZddlZddlZddlmZ ddlmZ ddl m
Z
mZmZ ddl
Z
ddlmZ ede
def � � Zdad
Z G d� de� Zd"d
�ZdZ G d� de� Zd� Z G d� d� Z G d� d� Z G d� d� Zg Zdedefd�Z G d� de� Z d� Z!dZ"dddde jF fd �Z$d!� Z%y)#z9
Asynchronous-friendly error mechanism.
See L{Failure}.
� N)�getmro)�StringIO)�Callable�NoReturn�TypeVar)�reflect�_T_Callable.)�bound� c � � e Zd Zy)�DefaultExceptionN)�__name__�
__module__�__qualname__� � �8/usr/lib/python3/dist-packages/twisted/python/failure.pyr
r
# s � �r r
c
�V � |dvrt d|�d�� �|}|dk( r| D ] \ }}}}} ||� d|� d|� d�� � y|dk( rM| D ]G \ }}}}} |d|� d |� d
|� d�� |dt j ||� j � z � �I y|dk( r$| D ] \ }}}}} |d
|||fz � � |d� y|dk( rp| D ]j \ }}}}} |d
|||fz � |d� |D ] \ } }
|d| � dt |
� � d�� � |d� |D ] \ } }
|d| � dt |
� � d�� � �l yy)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 �:�
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�lineno� localVars�
globalVars�name�vals r �
format_framesr, ' |