B
    v9an  ã               @   sV   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
 G dd„ dejƒZdS )é   )Ú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   sl  | j }|d  ¡ }|jtjkr2d}|  ||¡ d S t|ƒrbx t|ƒrZ|jd jd  ¡ }q<W d|_d|krŒt	 
|jtdƒ|g¡}|j|_|S |d  ¡ }t|ƒrºdd	„ |jdd
… D ƒ}nd|_|g}d|krF|d  ¡ }	d|	_|}
|jtjksþ|jdkrt||ƒ}
t|
tdƒƒt|	gƒg }t	 
|jtdƒg| ¡}|j|_|S t	j
|jtdƒt||ƒg|jdS d S )NÚexcz+Python 3 does not support string exceptionsé   é    ú ÚvalÚraisec             S   s   g | ]}|  ¡ ‘qS © )Úclone)Ú.0Úcr   r   ú/usr/lib/python3.7/fix_raise.pyú
<listcomp>D   s    z&FixRaise.transform.<locals>.<listcomp>éÿÿÿÿÚ ÚtbÚNoneÚwith_traceback)Úprefix)Úsymsr   Útyper   ÚSTRINGZcannot_convertr	   Zchildrenr   r   ZNodeZ
raise_stmtr   ÚNAMEÚvaluer   r   r   Zsimple_stmt)ÚselfZnodeÚresultsr   r   ÚmsgÚnewr   Úargsr   ÚeZwith_tbr   r   r   Ú	transform&   s@    


zFixRaise.transformN)Ú__name__Ú
__module__Ú__qualname__ZBM_compatibleZPATTERNr(   r   r   r   r   r
      s   r
   N)r   r   Zpgen2r   r   Z
fixer_utilr   r   r   r   r	   ZBaseFixr
   r   r   r   r   Ú<module>   s   