Ñò
$8Zc           @   s{   d  Z  d d k l Z d d k l Z d d k l Z d d k l Z l Z l	 Z	 l
 Z
 l Z d e i f d „  ƒ  YZ d S(	   s-  Fixer for 'raise E, V, T'

raise         -> raise
raise E       -> raise E
raise E, V    -> raise E(V)
raise E, V, T -> raise E(V).with_traceback(T)

raise (((E, E'), E''), E'''), V -> raise E(V)
raise "foo", V, T               -> warns about string exceptions


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   pytree(   t   token(   t
   fixer_base(   t   Namet   Callt   Attrt   ArgListt   is_tuplet   FixRaisec           B   s   e  Z d  Z d „  Z RS(   sB   
    raise_stmt< 'raise' exc=any [',' val=any [',' tb=any]] >
    c      	   C   sï  |  i  } | d i ƒ  } | i t i j o |  i | d ƒ d  St | ƒ o< x, t | ƒ o | i d i d i ƒ  } qQ Wd | _ n d | j o2 t	 i
 | i t d ƒ | g ƒ } | i | _ | S| d i ƒ  } t | ƒ o5 g  } | i d d !D] } | | i ƒ  qû ~ }	 n d	 | _ | g }	 d
 | j o€ | d
 i ƒ  }
 d	 |
 _ t | |	 ƒ } t | t d ƒ ƒ t |
 g ƒ g } t	 i
 | i t d ƒ g | ƒ } | i | _ | St	 i
 | i t d ƒ t | |	 ƒ g d | i ƒSd  S(   Nt   excs+   Python 3 does not support string exceptionsi   i    t    t   valu   raiseiÿÿÿÿu    t   tbu   with_tracebackt   prefix(   t   symst   clonet   typeR   t   STRINGt   cannot_convertR   t   childrenR   R    t   Nodet
   raise_stmtR   R   R   R   t   simple_stmt(   t   selft   nodet   resultsR   R	   t   newR   t   _[1]t   ct   argsR   t   et   with_tb(    (    s-   /usr/lib/python2.6/lib2to3/fixes/fix_raise.pyt	   transform$   s<    	 !5			%"(   t   __name__t
   __module__t   PATTERNR    (    (    (    s-   /usr/lib/python2.6/lib2to3/fixes/fix_raise.pyR      s   N(   t   __doc__t    R    t   pgen2R   R   t
   fixer_utilR   R   R   R   R   t   BaseFixR   (    (    (    s-   /usr/lib/python2.6/lib2to3/fixes/fix_raise.pyt   <module>   s
   (