hLo#
b d dl Z d dlZd dlZd dlmZ d dlmZ ddlmZ ddl m
Z
ddl mZ ej rddl
mZ dd ej e d
efdZded
ej e deded
ef
dZdej eej f d
ej eej f fdZej dk rd
edej e d
efdZdS e j dk r= d dlZd
edej e d
efdZdS # e$ r d
edej e d
efdZY dS w xY wd dlZ G d dej Z d
edej e d
efdZdS ) N)CodeType)
TracebackType )TemplateSyntaxError)
internal_code)missing)Contextsourcereturnc t j \ }}}t j t | }t j t
| }t
|t rI|j sBd|_ | |_ |
d t |d|j pd|j
}n|j }g }||j j t" v r|j }|j j d }|G| |j }t |||j | }| | n| | |j }|d}t/ | D ]}t1 || }|
| S )ax Rewrite 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