Viewing File: /opt/alt/python35/lib64/python3.5/lib2to3/fixes/__pycache__/fix_raise.cpython-35.pyc
¯ÕYfn ã @ s{ d Z d d l m Z d d l m Z d d l m Z d d l m Z m Z m Z m
Z
m Z Gd d „ d e j ƒ Z
d S) 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)ÚNameÚCallÚAttrÚArgListÚis_tuplec @ s( e Z d Z d Z d Z d d „ Z d S)ÚFixRaiseTzB
raise_stmt< 'raise' exc=any [',' val=any [',' tb=any]] >
c C sü | j } | d j ƒ } | j t j k rE d } | j | | ƒ d St | ƒ r‡ x* t | ƒ r} | j d j d j ƒ } qT Wd | _ d | k rÄ t j
| j t d ƒ | g ƒ } | j | _ | S| d j ƒ } t | ƒ rd d „ | j d d … Dƒ } n d
| _ | g } d | k rÇ| d j ƒ } d
| _ | }
| j t j
k sa| j d k rpt | | ƒ }
t |
t d
ƒ ƒ t | g ƒ g } t j
| j t d ƒ g | ƒ } | j | _ | St j
| j t d ƒ t | | ƒ g d | j ƒSd S)NÚexcz+Python 3 does not support string exceptionsé é ú ÚvalÚraisec S s g | ] } | j ƒ ‘ q S© )Úclone)Ú.0Úcr r ú</opt/alt/python35/lib64/python3.5/lib2to3/fixes/fix_raise.pyú
<listcomp>D s z&FixRaise.transform.<locals>.<listcomp>Ú ÚtbÚNoneÚwith_tracebackÚprefixéÿÿÿÿ)Úsymsr Útyper ÚSTRINGZcannot_convertr Zchildrenr r ZNodeZ
raise_stmtr ÚNAMEÚvaluer r r Zsimple_stmt)ÚselfZnodeZresultsr r ÚmsgÚnewr Úargsr ÚeZwith_tbr r r Ú transform&