ó
	Q[c           @   se   d  Z  d d l m Z m Z d d l m Z d d l m Z m Z m	 Z	 d e j
 f d     YZ d S(   sč  Fixer for 'raise E, V'

From Armin Ronacher's ``python-modernize``.

raise         -> raise
raise E       -> raise E
raise E, V    -> raise E(V)

raise (((E, E'), E''), E'''), V -> raise E(V)


CAVEATS:
1) "raise E, V" will be incorrectly translated if V is an exception
   instance. The correct Python 3 idiom is

        raise E from V

   but since we can't detect instance-hood by syntax alone and since
   any client code would have to be changed as well, we don't automate
   this.
i˙˙˙˙(   t   pytreet
   fixer_base(   t   token(   t   Namet   Callt   is_tuplet   FixRaisec           B   s   e  Z e Z d  Z d   Z RS(   s5   
    raise_stmt< 'raise' exc=any [',' val=any] >
    c   
      C   sR  |  j  } | d j   } | j t j k rE d } |  j | |  d  St |  r x* t |  r} | j d j d j   } qT Wd | _ n  d | k rÇ t	 j
 | j t d  | g  } | j | _ | S| d j   } t |  rg  | j d d !D] } | j   ^ qô }	 n d	 | _ | g }	 t	 j
 | j t d  t | |	  g d
 | j S(   Nt   excs+   Python 3 does not support string exceptionsi   i    u    t   valu   raisei˙˙˙˙u    t   prefix(   t   symst   clonet   typeR   t   STRINGt   cannot_convertR   t   childrenR	   R    t   Nodet
   raise_stmtR   R   (
   t   selft   nodet   resultsR
   R   t   msgt   newR   t   ct   args(    (    s:   lib/python2.7/site-packages/libfuturize/fixes/fix_raise.pyt	   transform$   s,    	!,		(   t   __name__t
   __module__t   Truet   BM_compatiblet   PATTERNR   (    (    (    s:   lib/python2.7/site-packages/libfuturize/fixes/fix_raise.pyR      s   N(   t   __doc__t   lib2to3R    R   t   lib2to3.pgen2R   t   lib2to3.fixer_utilR   R   R   t   BaseFixR   (    (    (    s:   lib/python2.7/site-packages/libfuturize/fixes/fix_raise.pyt   <module>   s   