Your IP : 3.128.201.71
3
\
� @ sb d dl mZ d dlmZ d dl mZ d dlmZmZmZm Z m
Z
mZ dd� ZG dd� dej
�Zd S )
� )�pytree)�token)�
fixer_base)�Assign�Attr�Name�is_tuple�is_list�symsc c sH xBt | �D ]6\}}|jtjkr
|jd jdkr
|| |d fV q
W d S )N� �exceptr )� enumerate�typer
�
except_clause�children�value)Znodes�i�n� r �0/usr/lib64/python3.6/lib2to3/fixes/fix_except.py�find_excepts s r c @ s e Zd ZdZdZdd� ZdS )� 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 }dd� |d D �}dd� |d D �}�x*t|�D �]\}}t|j�dkr6|jdd� \}} }
| jtdd d
�� |
jtjk�rDt| j � d d
�}|
j
� }d|_|
j|� |j
� }|j}
x"t|
�D ]\}}t
|tj�r�P q�W t|
�s�t|
��rt|t|td���}n
t||�}x&t|
d |� �D ]}|jd
|� �q W |j||� q6|
jdkr6d |
_q6W dd� |jd d� D �| | }tj|j|�S )Nc S s g | ]}|j � �qS r )�clone)�.0r r r r �
<listcomp>2 s z'FixExcept.transform.<locals>.<listcomp>�tailc S s g | ]}|j � �qS r )r )r Zchr r r r 4 s Zcleanup� � �as� )�prefix� �argsr c S s g | ]}|j � �qS r )r )r �cr r r r \ s � )r
r �lenr �replacer r r �NAME�new_namer r r
�
isinstancer ZNoder r r r �reversedZinsert_child)�selfZnodeZresultsr
r Ztry_cleanupr Ze_suite�EZcomma�NZnew_N�targetZsuite_stmtsr ZstmtZassignZchildr r r r � transform/ s6
zFixExcept.transformN)�__name__�
__module__�__qualname__Z
BM_compatibleZPATTERNr/ r r r r r $ s r N)r! r Zpgen2r r Z
fixer_utilr r r r r r
r ZBaseFixr r r r r �<module> s