o ,],@sbdZddlmZmZddlmZddlmZmZm Z m Z m Z m Z ddl mZGdddejZdS) aFixer for 'raise E, V' From Armin Ronacher's ``python-modernize``. raise -> raise raise E -> raise E raise E, 5 -> raise E(5) raise E, 5, T -> raise E(5).with_traceback(T) raise E, None, T -> raise E.with_traceback(T) raise (((E, E'), E''), E'''), 5 -> raise E(5) raise "foo", V, T -> warns about string exceptions raise E, (V1, V2) -> raise E(V1, V2) raise E, (V1, V2), T -> raise E(V1, V2).with_traceback(T) CAVEATS: 1) "raise E, V, T" cannot be translated safely in general. If V is not a tuple or a (number, string, None) literal, then: raise E, V, T -> from future.utils import raise_ raise_(E, V, T) )pytree fixer_base)token)NameCallis_tupleCommaAttrArgList)touch_import_topc@seZdZdZdZddZdS)FixRaiseTzB raise_stmt< 'raise' exc=any [',' val=any [',' tb=any]] > c Cs|j}|d}|jtjkrd}|||dSt|r2t|r/|jdjd}t|s!d|_d|vr=|d}nd}d|vr|d}t|r_dd |jdd D}t ||}n@|jtj tjfvrrd |_t ||g}n-|jtj kr~|j d kr~n!t d d|d |_|t|g}|dur|t|g7}t td|S|durd |_t|tdt|gg} n|g} tj|jtdg| |jdS)Nexcz+Python 3 does not support string exceptionsr tbvalcSsg|]}|qS)clone).0crr=/usr/lib/python3/dist-packages/libfuturize/fixes/fix_raise.py Isz&FixRaise.transform..Nonez future.utilsraise_with_tracebackraise)prefix)symsrtyperSTRINGcannot_convertrchildrenrrNUMBERNAMEvaluer rrr r rNode raise_stmt) selfnoderesultsrr msgrrargsexc_listrrr transform*sL        zFixRaise.transformN)__name__ __module__ __qualname__ BM_compatiblePATTERNr/rrrrr #s r N)__doc__lib2to3rr lib2to3.pgen2rlib2to3.fixer_utilrrrrr r libfuturize.fixer_utilr BaseFixr rrrrs