
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
U
    ,a.                     @   sZ   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 G dd dejZdS )	zFixer for generator.throw(E, V, T).

g.throw(E)       -> g.throw(E)
g.throw(E, V)    -> g.throw(E(V))
g.throw(E, V, T) -> g.throw(E(V).with_traceback(T))

g.throw("foo"[, V[, T]]) will warn about string exceptions.   )pytree)token)
fixer_base)NameCallArgListAttris_tuplec                   @   s   e Zd ZdZdZdd ZdS )FixThrowTz
    power< any trailer< '.' 'throw' >
           trailer< '(' args=arglist< exc=any ',' val=any [',' tb=any] > ')' >
    >
    |
    power< any trailer< '.' 'throw' > trailer< '(' exc=any ')' > >
    c                 C   s   | j }|d  }|jtjkr.| |d d S |d}|d krDd S | }t|rndd |jdd D }nd|_	|g}|d	 }d
|kr|d
  }d|_	t
||}	t|	tdt|gg }
|t|j|
 n|t
|| d S )Nexcz+Python 3 does not support string exceptionsvalc                 S   s   g | ]}|  qS  )clone).0cr   r   </opt/alt/python38/lib64/python3.8/lib2to3/fixes/fix_throw.py
<listcomp>)   s     z&FixThrow.transform.<locals>.<listcomp>    argstbwith_traceback)symsr   typer   STRINGZcannot_convertgetr	   Zchildrenprefixr   r   r   r   replacer   ZNodeZpower)selfZnodeZresultsr   r   r   r   Z
throw_argsr   eZwith_tbr   r   r   	transform   s*    

zFixThrow.transformN)__name__
__module____qualname__ZBM_compatibleZPATTERNr!   r   r   r   r   r
      s   r
   N)__doc__r   r   Zpgen2r   r   Z
fixer_utilr   r   r   r   r	   ZBaseFixr
   r   r   r   r   <module>   s
   
