
    dafn                     r    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ej                        Zy)	a[  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, None, T -> raise E.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.
   )pytree)token)
fixer_base)NameCallAttrArgListis_tuplec                       e Zd ZdZdZd Zy)FixRaiseTzB
    raise_stmt< 'raise' exc=any [',' val=any [',' tb=any]] >
    c                 v   | j                   }|d   j                         }|j                  t        j                  k(  rd}| j                  ||       y t        |      rHt        |      r6|j                  d   j                  d   j                         }t        |      r6d|_        d|vr>t        j                  |j                  t        d      |g      }|j                  |_        |S |d   j                         }t        |      r+|j                  dd D cg c]  }|j                          }	}n
d	|_        |g}	d
|v r|d
   j                         }
d	|
_        |}|j                  t        j                  k7  s|j                  dk7  rt        ||	      }t!        |t        d            t#        |
g      gz   }t        j                  |j$                  t        d      g|z         }|j                  |_        |S t        j                  |j                  t        d      t        ||	      g|j                        S c c}w )Nexcz+Python 3 does not support string exceptions        valraise tbNonewith_traceback)prefix)symsclonetyper   STRINGcannot_convertr
   childrenr   r   Node
raise_stmtr   NAMEvaluer   r   r	   simple_stmt)selfnoderesultsr   r   msgnewr   cargsr   ewith_tbs                2/root/Python-3.12.4/Lib/lib2to3/fixes/fix_raise.py	transformzFixRaise.transform&   s   yyen""$88u||#?Cc* C=3- ll1o..q1779 3- CJ++dooWs/CDCCJJen""$C='*||Ab'9:!AGGI:D:CJ5D7?$$&BBIA xx5::%f)<dO1d#345"GG++d..g'0IJCCJJ;;t $WtC?&*kk3 3) ;s   H6N)__name__
__module____qualname__BM_compatiblePATTERNr/        r.   r   r      s    MG43r6   r   N)__doc__r   r   pgen2r   r   
fixer_utilr   r   r   r	   r
   BaseFixr   r5   r6   r.   <module>r;      s-   2    < <;3z!! ;3r6   