î
\á[\.  ã               @   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 Gd d „  d e j ƒ Z d S)	zÖFixer 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   sG  |  j  } | d j ƒ  } | j t j k r? |  j | d ƒ d  S| j d ƒ } | d  k r^ d  S| j ƒ  } t | ƒ r™ d d „  | j d d … Dƒ } n d | _	 | g } | d } d	 | k r-| d	 j ƒ  } d | _	 t
 | | ƒ }	 t |	 t d
 ƒ ƒ t | g ƒ g }
 | j t j | j |
 ƒ ƒ n | j t
 | | ƒ ƒ d  S)NÚexcz+Python 3 does not support string exceptionsÚvalc             S   s   g  |  ] } | j  ƒ  ‘ q S© )Úclone)Ú.0Úcr   r   ú-/usr/lib/python3.4/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
   (