zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
U
Þ=®d›ã@s¾ddlZddlZddlmZddlmZddlmZddlm    Z    ddlm
Z
ej r^ddl m Z dejeed    œd
d „Zeejeeeed œd d„Zejeejfejeejfdœdd„ZdS)éN)ÚCodeType)Ú TracebackTypeé)ÚTemplateSyntaxError)Ú internal_code)Úmissing)ÚContext)ÚsourceÚreturnc    Cst ¡\}}}t t|¡}t t|¡}t|tƒrd|jsdd|_||_    | 
d¡t |d|j pZd|j ƒ}n|j}g}|dk    rÚ|jjtkrŠ|j}qn|jj d¡}|dk    rÈ| |j¡}t |||j |ƒ}| |¡n
| |¡|j}qnd}t|ƒD]}||_|}qæ| 
|¡S)axRewrite the current exception to replace any tracebacks from
    within compiled template code with tracebacks that look like they
    came from the template source.
 
    This must be called within an ``except`` block.
 
    :param source: For ``TemplateSyntaxError``, the original source if
        known.
    :return: The original exception with the rewritten traceback.
    TNz    <unknown>Z__jinja_template__)ÚsysÚexc_infoÚtÚcastÚ BaseExceptionrÚ
isinstancerZ
translatedr    Úwith_tracebackÚfake_tracebackÚfilenameÚlinenoÚtb_nextÚtb_frameÚf_coderÚ    f_globalsÚgetZget_corresponding_linenoÚ    tb_linenoÚappendÚreversed)    r    Ú_Ú    exc_valueÚtbÚstackÚtemplaterZfake_tbr©r"úCd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\jinja2/debug.pyÚrewrite_traceback_stacks>   
ÿ   
 r$)rrrrr
c    Cs|dk    r"t|jjƒ}| dd¡ni}|||dœ}td|dd|dƒ}d}|dk    rŠ|jjj}|d    krnd
}n| d ¡rŠd |d d…›}tj    dkr¢|j
|d}n@t |j |j |j|j|j|j|j|j|j|j||j|j|j|jƒ}zt|||ƒWn$tk
rt ¡djYSXdS)a,Produce a new traceback object that looks like it came from the
    template source instead of the compiled code. The filename, line
    number, and location name will point to the template, and the local
    variables will be the current template context.
 
    :param exc_value: The original exception to be re-raised to create
        the new traceback.
    :param tb: The original traceback to get the local variables and
        code info from.
    :param filename: The template filename.
    :param lineno: The line number in the template source.
    NÚ__jinja_exception__)Ú__name__Ú__file__r%Ú
rzraise __jinja_exception__Úexecr!Úrootztop-level template codeZblock_zblock é)éé)Úco_nameé)Úget_template_localsrÚf_localsÚpopÚcompilerr.Ú
startswithr Ú version_infoÚreplacerÚ co_argcountÚco_kwonlyargcountÚ
co_nlocalsÚ co_stacksizeÚco_flagsÚco_codeÚ    co_constsÚco_namesÚ co_varnamesÚ co_filenameÚco_firstlinenoÚ    co_lnotabÚ co_freevarsÚ co_cellvarsr)rr r)    rrrrÚlocalsÚglobalsÚcodeÚlocationÚfunctionr"r"r#rLsV ýÿ
 
 
ñr)Ú real_localsr
c
    Csâ| d¡}|dk    r | ¡ ¡}ni}i}| ¡D]x\}}| d¡r0|tkrLq0z| dd¡\}}}t|ƒ}Wntk
r‚Yq0YnX| |d¡d}    |    |kr0||f||<q0| ¡D]*\}\}}|tkrÔ|     |d¡q²|||<q²|S)zlBased on the runtime locals, get the context that would be
    available at that point in the template.
    ÚcontextNZl_rr/)éÿÿÿÿr)
rÚget_allÚcopyÚitemsr4rÚsplitÚintÚ
ValueErrorr2)
rJÚctxÚdataZlocal_overridesÚnameÚvaluerZ    depth_strÚdepthZ    cur_depthr"r"r#r0–s*
 
 
r0)N)r Útypingr ÚtypesrrÚ
exceptionsrÚutilsrrÚ TYPE_CHECKINGZruntimerÚOptionalÚstrrr$rQrÚMappingÚAnyÚDictr0r"r"r"r#Ú<module>s       ?þ J