ðÕYf
ã @ 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 m Z d d „ Z
Gd d „ d e j ƒ Z d
S)aª Fixer for except statements with named exceptions.
The following cases will be converted:
- "except E, T:" where T is a name:
except E as T:
- "except E, T:" where T is not a name, tuple or list:
except E as t:
T = t
This is done because the target of an "except" clause must be a
name.
- "except E, T:" where T is a tuple or list literal:
except E as t:
T = t.args
é )Úpytree)Útoken)Ú
fixer_base)ÚAssignÚAttrÚNameÚis_tupleÚis_listÚsymsc c s\ xU t | ƒ D]G \ } } | j t j k r
| j d j d k r
| | | d f Vq
Wd S)Né Úexceptr )Ú enumerateÚtyper
Ú
except_clauseÚchildrenÚvalue)ZnodesÚiÚn© r ú=/opt/alt/python35/lib64/python3.5/lib2to3/fixes/fix_except.pyÚfind_excepts s r c @ s( e Z d Z d Z d Z d d „ Z d S)Ú FixExceptTa1
try_stmt< 'try' ':' (simple_stmt | suite)
cleanup=(except_clause ':' (simple_stmt | suite))+
tail=(['except' ':' (simple_stmt | suite)]
['else' ':' (simple_stmt | suite)]
['finally' ':' (simple_stmt | suite)]) >
c C s | j } d d „ | d Dƒ } d d „ | d Dƒ } x™t | ƒ D]‹\ } } t | j ƒ d k rD | j d d … \ } } }
| j t d d d
ƒƒ |
j t j k r·t | j ƒ d d
ƒ} |
j
ƒ } d | _ |
j | ƒ | j
ƒ } | j }
x- t |
ƒ D] \ } } t
| t j ƒ rPqWt |
ƒ sCt |
ƒ rdt | t | t d ƒ ƒ ƒ } n t | | ƒ } x. t |
d | … ƒ D] } | j d
| ƒ qŠW| j | | ƒ qD |
j d k rD d
|
_ qD Wd d „ | j d d … Dƒ | | } t j | j | ƒ S)Nc S s g | ] } | j ƒ ‘ q Sr )Úclone)Ú.0r r r r ú