tzh
2024-08-22 c7d0944258c7d0943aa7b2211498fd612971ce27
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
Y\¬Qc@s{dZddlmZddlmZddlmZddlmZmZm    Z    m
Z
m Z dej fd„ƒYZ dS(    s[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.
i(tpytree(ttoken(t
fixer_base(tNametCalltAttrtArgListtis_tupletFixRaisecBseZeZdZd„ZRS(sB
    raise_stmt< 'raise' exc=any [',' val=any [',' tb=any]] >
    c Cs |j}|djƒ}|jtjkrEd}|j||ƒdSt|ƒrŠx*t|ƒr}|jdjdjƒ}qTWd|_nd|krÇt    j
|j t dƒ|gƒ}|j|_|S|djƒ}t|ƒrg|jdd!D]}|jƒ^qô}    nd    |_|g}    d
|krÖ|d
jƒ}
d    |
_|} |jtj ksm|jd krt||    ƒ} nt| t d ƒƒt|
gƒg} t    j
|jt dƒg| ƒ}|j|_|St    j
|j t dƒt||    ƒgd |jƒSdS(Ntexcs+Python 3 does not support string exceptionsiiu tvaluraiseiÿÿÿÿuttbuNoneuwith_tracebacktprefix(tsymstclonettypeRtSTRINGtcannot_convertRtchildrenR RtNodet
raise_stmtRtNAMEtvalueRRRt simple_stmt( tselftnodetresultsR R    tmsgtnewR
tctargsR tetwith_tb((s_/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/fixes/fix_raise.pyt    transform&s@       !  ,             !%"  (t__name__t
__module__tTruet BM_compatibletPATTERNR!(((s_/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/fixes/fix_raise.pyRsN(t__doc__tRtpgen2RRt
fixer_utilRRRRRtBaseFixR(((s_/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/fixes/fix_raise.pyt<module>s
(