o
    bc.                     @   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u r| |d d S |d}|d u r"d S | }t|r7dd |jdd D }nd|_	|g}|d	 }d
|v rl|d
  }d|_	t
||}	t|	tdt|gg }
|t|j|
 d S |t
|| d S )Nexcz+Python 3 does not support string exceptionsvalc                 S   s   g | ]}|  qS  )clone).0cr   r   ./usr/lib/python3.10/lib2to3/fixes/fix_throw.py
<listcomp>)   s    z&FixThrow.transform.<locals>.<listcomp>    argstbwith_traceback)symsr   typer   STRINGcannot_convertgetr	   childrenprefixr   r   r   r   replacer   Nodepower)selfnoderesultsr   r   r   r   
throw_argsr   ewith_tbr   r   r   	transform   s*   

zFixThrow.transformN)__name__
__module____qualname__BM_compatiblePATTERNr)   r   r   r   r   r
      s    r
   N)__doc__r   r   pgen2r   r   
fixer_utilr   r   r   r   r	   BaseFixr
   r   r   r   r   <module>   s    
