\dn pdZddlmZddlmZddlmZddlmZmZm Z m Z m Z Gddej Z dS) a[Fixer for 'raise E, V, T' raise -> raise raise E -> raise E raise E, V -> raise E(V) raise E, V, T -> raise E(V).with_traceback(T) raise E, None, T -> raise E.with_traceback(T) raise (((E, E'), E''), E'''), V -> raise E(V) raise "foo", V, T -> warns about string exceptions CAVEATS: 1) "raise E, V" will be incorrectly translated if V is an exception instance. The correct Python 3 idiom is raise E from V but since we can't detect instance-hood by syntax alone and since any client code would have to be changed as well, we don't automate this. )pytree)token) fixer_base)NameCallAttrArgListis_tupleceZdZdZdZdZdS)FixRaiseTzB raise_stmt< 'raise' exc=any [',' val=any [',' tb=any]] > ch|j}|d}|jtjkrd}|||dSt |rOt |r9|jdjd}t |9d|_d|vr7tj |j td|g}|j|_|S|d}t |rd|jdd D}n d |_|g}d |vr|d } d | _|} |jtj ks |jd krt||} t!| td t#| ggz} tj |jtdg| z}|j|_|Stj |j tdt||g|jS)Nexcz+Python 3 does not support string exceptions valraisec6g|]}|S)clone).0cs (..\python\lib\lib2to3\fixes\fix_raise.py z&FixRaise.transform..Ds :::!AGGII:::tbNonewith_traceback)prefix)symsrtyperSTRINGcannot_convertr childrenr!rNode raise_stmtrNAMEvaluerrr simple_stmt) selfnoderesultsr"rmsgnewrargsrewith_tbs r transformzFixRaise.transform&syen""$$ 8u| # #?C   c * * * F C== 3-- :l1o.q177993-- :CJ   +doW s/CDDCCJJen""$$ C== ::s|AbD'9:::DDCJ5D 7??$$&&BBIAx5:%%f)<)<dOO1d#34455"GG+d.g'0IJJCCJJ;t $W tC?&*k333 3rN)__name__ __module__ __qualname__ BM_compatiblePATTERNr4rrrr r s/MG4343434343rr N)__doc__rrpgen2rr fixer_utilrrrr r BaseFixr rrrr>s2<<<<<<<<<<<<<<;3;3;3;3;3z!;3;3;3;3;3r