
    DgE                        d dl Z d dlZd dlZd dlmZmZmZ d dlmZm	Z	 d dl
Z
e j        j        Z G d d          Z G d de          Zd Z G d	 d
e          Z G d de          Z G d de          Z G d de          Z G d de          Zg Zej        dej        di                                D ](\  ZZ G d de          Ze                    e           )ej        dej         dej!        dej"        dej#        dej$        di                                D ](\  ZZ G d de          Z%e                    e%           ) G d d e          Z& G d! d"e          Z' G d# d$e          Z( G d% d&e          Z) G d' d(e          Z* G d) d*e          Z+d+ Z,dFd,Z-dGd.Z.d/ Z/d0 Z0dFd1Z1e2d2k    rd3 Z3d4 Z4d5 Z5 e-d6            e-d7            e-d8            e-d9           d:Z6 e-d;            e-d<            e-d=            e1d>            e-d?            e1d@            e1dA            e1dB            e-dC            e-dD            e1dE           dS dS )H    N)parseast	pycodegen)BuiltinAssertionError_format_explanationc                       e Zd Zd ZdS )Failurec                 `    t          j                    \  | _        | _        | _        || _        d S N)sysexc_infoexcvaluetbnode)selfr   s     K/var/www/sysmax/venv/lib/python3.11/site-packages/py/_code/_assertionold.py__init__zFailure.__init__
   s%    (+%$*dg			    N)__name__
__module____qualname__r    r   r   r	   r	   	   s#            r   r	   c                   >    e Zd ZdZi ZdZd Zd Zd Zd Z	d Z
d Zd	S )
Viewa  View base class.

    If C is a subclass of View, then C(x) creates a proxy object around
    the object x.  The actual class of the proxy is not C in general,
    but a *subclass* of C determined by the rules below.  To avoid confusion
    we call view class the class of the proxy (a subclass of C, so of View)
    and object class the class of x.

    Attributes and methods not found in the proxy are automatically read on x.
    Other operations like setting attributes are performed on the proxy, as
    determined by its view class.  The object x is available from the proxy
    as its __obj__ attribute.

    The view class selection is determined by the __view__ tuples and the
    optional __viewkey__ method.  By default, the selected view class is the
    most specific subclass of C whose __view__ mentions the class of x.
    If no such subclass is found, the search proceeds with the parent
    object classes.  For example, C(True) will first look for a subclass
    of C with __view__ = (..., bool, ...) and only if it doesn't find any
    look for one with __view__ = (..., int, ...), and then ..., object,...
    If everything fails the class C itself is considered to be the default.

    Alternatively, the view class selection can be driven by another aspect
    of the object x, instead of the class of x, by overriding __viewkey__.
    See last example at the end of this module.
    r   c                     t                               |           }||_        | |_        |                                }	 |j        |         |_        n*# t          $ r |                    |          |_        Y nw xY w|S r   )	object__new____obj____rootclass____viewkey__
_viewcache	__class__KeyError_selectsubclass)	rootclassobjargskwdsr   keys         r   r   zView.__new__-   s    ~~i((&  	7!_S1DNN 	7 	7 	7!11#66DNNN	7s   A $A87A8c                 ,    t          | j        |          S r   )getattrr   )r   attrs     r   __getattr__zView.__getattr__8   s     t|T***r   c                     | j         j        S r   )r   r#   r   s    r   r!   zView.__viewkey__=   s    |%%r   c                     t          j                  rt          j                  }ng}|D ]fd|D             }|r|c S g S )Nc                 &    g | ]}|j         v |S r   )__view__).0Cr*   s     r   
<listcomp>z%View.__matchkey__.<locals>.<listcomp>F   s%    AAAAsaj/@/@a/@/@/@r   )inspectisclassgetmro)r   r*   
subclasseskeysresults    `   r   __matchkey__zView.__matchkey__@   sp    ?3 	>#&&DD5D 	 	CAAAAAAAF 	r   c                 L   t          t          | j                            }|D ])}t          |j        t
                    s|j        f|_        *|                     ||          }|s| j        S t          |          dk    r|d         S t          dt          |          i           S )N   r   ?)	listenumsubclassesr    
isinstancer3   tupler=   lentype)r   r*   r:   r5   choicess        r   r%   zView._selectsubclassK   s    .);<<==
 	+ 	+Aaj%00 +j]
##C44 	1%%\\Q1: U7^^R000r   c                 0    | j         j        d| j        dS )N())r    r   r   r0   s    r   __repr__zView.__repr__Y   s    -666EEr   N)r   r   r   __doc__r"   r3   r   r.   r!   r=   r%   rK   r   r   r   r   r      s         6 JH	 	 	+ + +
& & &	 	 	1 1 1F F F F Fr   r   c              #   l   K   |                                  D ]}t          |          D ]}|V  | V  d S r   )__subclasses__rB   )clssubclssubsubclasss      r   rB   rB   ]   sY      $$&&  )&11 	 	K	
IIIIIr   c                   .    e Zd ZdZdZd Zd Zd Zd ZdS )Interpretablez+A parse tree node with a few extra methods.Nc                     dS )NFr   )r   frames     r   
is_builtinzInterpretable.is_builtinh   s    ur   c                 n   	 t          j        | j                  }d|_        d| j        _        t	          j        |                                          }|                    |          }n# t          $ r   t          |           xY w|| _
        | j        p|                    | j
                  | _        d S )Nz<eval>)r   
Expressionr   filenamer   ExpressionCodeGeneratorgetCodeevalpassthroughexr	   r<   explanationrepr)r   rU   exprcor<   s        r   r\   zInterpretable.evalk   s    		 >$,//D$DM$,DL!2488@@BBBZZ^^FF 	 	 		 $--+Fuzz$+/F/Fs   A'A* *Bc                 "   	 t          j        d t          j        | j        g                    }d|_        t          j        |                                          }|                    |           d S # t          $ r   t          |           xY w)N<run>)r   ModuleStmtr   rY   r   ModuleCodeGeneratorr[   exec_r]   r	   )r   rU   r`   ra   s       r   runzInterpretable.runz   s    	 :dCHdl^$<$<==D#DM.t44<<>>BKKOOOOO 	 	 		 $--s   A/A3 3Bc                 *    t          | j                  S r   )r   r^   r0   s    r   nice_explanationzInterpretable.nice_explanation   s    "4#3444r   )	r   r   r   rL   r^   rV   r\   rh   rj   r   r   r   rS   rS   d   s^        55K  G G G
  
  
 5 5 5 5 5r   rS   c                   >     e Zd Zej        Zd Zd Zd Z fdZ	 xZ
S )Namec                     d| j         z  }	 |                    |                    |                    S # t          $ r   Y dS xY w)Nz%r in locals() is not globals()Fnameis_truer\   r]   r   rU   sources      r   is_localzName.is_local   sV    2TY>	==F!3!3444 	 	 		55	   '4 Ac                     d| j         z  }	 |                    |                    |                    S # t          $ r   Y dS xY w)Nz%r in globals()Frn   rq   s      r   	is_globalzName.is_global   sV    "TY.	==F!3!3444 	 	 		55rt   c                     | j         d| j         d}	 |                    |                    |                    S # t          $ r   Y dS xY w)Nz not in locals() and z not in globals()Frn   rq   s      r   rV   zName.is_builtin   sb    IIItyyy"	==F!3!3444 	 	 		55s	   '< Ac                     t          t          |                               |           |                     |          s| j        | _        d S d S r   )superrl   r\   rs   ro   r^   )r   rU   r#   s     r   r\   z	Name.eval   sO    dDu%%%}}U## 	)#yD	) 	)r   )r   r   r   r   rl   r3   rs   rv   rV   r\   __classcell__)r#   s   @r   rl   rl      sl        xH      ) ) ) ) ) ) ) ) )r   rl   c                   "    e Zd Zej        Zd ZdS )Comparec                    t          | j                  }|                    |           | j        D ]\  }}t	          | d          r|                    | j                  s d S t          |          }|                    |           |j        d|d|j        | _        d|z  }	 |                    ||j        |j                  | _        n# t          $ r   t          |           xY w|}d S )Nr<    z#__exprinfo_left %s __exprinfo_right__exprinfo_left__exprinfo_right)
rS   r`   r\   opshasattrrp   r<   r^   r]   r	   )r   rU   r`   	operationexpr2rr   s         r   r\   zCompare.eval   s"   TY''		% $ 	 	IutX&& }}T[11 EE!%((EJJu   )))U->-> @D:YFF$#jj9=:?, ) H H !   $dmm#DD%	 	s   &'CC)N)r   r   r   r   r|   r3   r\   r   r   r   r|   r|      s*        {H    r   r|   c                   "    e Zd Zej        Zd ZdS )Andc                 *   g }| j         D ]h}t          |          }|                    |           |                    |j                   |j        | _        |                    |j                  s nidd                    |          z   dz   | _        d S )NrI   z and rJ   nodesrS   r\   appendr^   r<   rp   joinr   rU   explanationsr`   s       r   r\   zAnd.eval   s    J 	 	D &&DIIe 0111+DK==-- l!;!;;cAr   N)r   r   r   r   r   r3   r\   r   r   r   r   r      s/        wH	B 	B 	B 	B 	Br   r   c                   "    e Zd Zej        Zd ZdS )Orc                 *   g }| j         D ]h}t          |          }|                    |           |                    |j                   |j        | _        |                    |j                  r nidd                    |          z   dz   | _        d S )NrI   z or rJ   r   r   s       r   r\   zOr.eval   s    J 	 	D &&DIIe 0111+DK}}T[)) \!:!::S@r   N)r   r   r   r   r   r3   r\   r   r   r   r   r      s/        vH	A 	A 	A 	A 	Ar   r   znot __exprinfo_exprz(~__exprinfo_expr)c                       e Zd ZeZefdZdS )
UnaryArithc                    t          | j                  }|                    |           |                    d|j                  | _        	 |                    ||j                  | _        d S # t          $ r   t          |           xY w)N__exprinfo_exprr   )rS   r`   r\   replacer^   r<   r]   r	   )r   rU   
astpatternr`   s       r   r\   zUnaryArith.eval   s     ++DIIe)112C262B D  DD$#jj9= ) F F    $dmm#s   !A. .B	Nr   r   r   astclassr3   r   r\   r   r   r   r   r      s0        )3 	$ 	$ 	$ 	$ 	$ 	$r   r   z$(__exprinfo_left + __exprinfo_right)z$(__exprinfo_left - __exprinfo_right)z$(__exprinfo_left * __exprinfo_right)z$(__exprinfo_left / __exprinfo_right)z$(__exprinfo_left % __exprinfo_right)z%(__exprinfo_left ** __exprinfo_right)c                       e Zd ZeZefdZdS )BinaryArithc                    t          | j                  }|                    |           t          | j                  }|                    |           |                    d|j                                      d|j                  | _        	 |                    ||j        |j                  | _        d S # t          $ r   t          |           xY w)Nr   r   r   )	rS   leftr\   rightr   r^   r<   r]   r	   )r   rU   r   r   r   s        r   r\   zBinaryArith.eval  s     ++DIIe!$*--EJJu *!():T=N!O!O!();U=N!O!O $#jj9=:?, ) H H !   $dmm#s   'B6 6CNr   r   r   r   r   r     s0        )3 	$ 	$ 	$ 	$ 	$ 	$r   r   c                   (    e Zd Zej        Zd Zd ZdS )CallFuncc                     d}	 |                     |                    || j                            S # t          $ r   Y dS xY w)Nz"isinstance(__exprinfo_value, bool))__exprinfo_valueF)rp   r\   r<   r]   rq   s      r   is_boolzCallFunc.is_bool"  sh    5	==F=A[ ", "J "J K K K 	 	 		55s	   .3 Ac                 8   t          | j                  }|                    |           g }d|j        i}d}| j        D ]}t          |t          j                  r|j        }|j	        }nd }t          |          }|                    |           dt          |          z  }|j        ||<   |#||dz   z  }|                    |j                   ||d|dz  }|                    |d|j                   | j        r]t          | j                  }	|	                    |           d}|	j        ||<   |d|z   dz   z  }|                    d|	j        z              | j        r]t          | j                  }
|
                    |           d}|
j        ||<   |d	|z   dz   z  }|                    d	|
j        z              |j        d
d                    |          d| _        |                    d          r
|d d         }|dz  }	  |j        |fi || _        n# t"          $ r   t%          |           xY w|                    |          r|                     |          s1|                    | j                  }|d|d| j        d| _        d S d S )N__exprinfo_fnz__exprinfo_fn(z__exprinfo_%d,=__exprinfo_star*__exprinfo_kwdsz**rI   z, rJ   
{ = 
})rS   r   r\   r<   r(   rC   r   Keywordro   r`   rE   r   r^   	star_args
dstar_argsr   endswithr]   r	   rV   r   r_   )r   rU   r   r   varsrr   akeywordargnamer   r   rs               r   r\   zCallFunc.eval,  s   TY''		%-! 	H 	HA!S[)) &Fa  AFF5MMM%D		1GHDM'C-'##AM2222gggwww77##www$FGGGG> 	=%dn55INN5!!!'G%,DMcGmc))Fi&; ;<<<? 	?&t77JOOE"""'G&-DMdWns**Fz'= =>>>dii55557??3 	!CRC[F#	 $%*V44t44DKK 	 	 		 $--u%% 	LT\\%-@-@ 	L

4;''A45AAqqq$:J:J:JKD	L 	Ls   H! !H<N)r   r   r   r   r   r3   r   r\   r   r   r   r   r     s>        |H  1L 1L 1L 1L 1Lr   r   c                   "    e Zd Zej        Zd ZdS )Getattrc                    t          | j                  }|                    |           d| j        z  }	 |                    ||j                  | _        n# t
          $ r   t          |           xY w|j        d| j        | _        d| j        z  }	 |                    |                    ||j                            }n# t
          $ r   d}Y nxY w|r1|	                    | j                  }|d|d| j        d| _        d S d S )	Nz__exprinfo_expr.%sr   .zGhasattr(__exprinfo_expr, "__dict__") and %r in __exprinfo_expr.__dict__Tr   r   r   )
rS   r`   r\   attrnamer<   r]   r	   r^   rp   r_   )r   rU   r`   rr   from_instancer   s         r   r\   zGetattr.evalb  sK   TY''		%%5	 **VT[*IIDKK 	 	 		 $--&*&6&6&6F359]C	!!MM

64;
??A AMM 	 	 		! MMM 	L

4;''A45AAqqq$:J:J:JKD	L 	Ls   !A A2/C CN)r   r   r   r   r   r3   r\   r   r   r   r   r   _  s/        {HL L L L Lr   r   c                   "    e Zd Zej        Zd ZdS )Assertc                    t          | j                  }|                    |           |j                            d          r.|j                            d          r|j        dd         |_        |j        | _        d|j        z   | _        |                    |j                  s&	 t          # t          $ r   t          |           xY wd S )NzFalse
{False = r      zassert )rS   testr\   r^   
startswithr   r<   rp   r   r]   r	   )r   rU   r   s      r   rh   z
Assert.run  s    TY''		%''(:;; 	7%%e,,	7#/26Dk$t'77}}T[)) 	$$++    $dmm#	$ 	$s   (B/ /C
N)r   r   r   r   r   r3   rh   r   r   r   r   r   }  s*        zH$ $ $ $ $r   r   c                   "    e Zd Zej        Zd ZdS )Assignc                    t          | j                  }|                    |           |j        | _        d|j        z   | _        t          j        | j        t          j        d                    }t          j	        d t          j
        |g                    }d|_        t          j        |                                          }	 |                    ||j                   d S # t           $ r   t#          |           xY w)Nz... = r   rc   r   )rS   r`   r\   r<   r^   r   r   r   rl   rd   re   rY   r   rf   r[   rg   r]   r	   )r   rU   r`   assmodra   s         r   rh   z
Assign.run  s    TY''		%k#d&66jSX.?%@%@AAjsx//*3//7799	 KKDKK88888 	 	 		 $--s   C% %D N)r   r   r   r   r   r3   rh   r   r   r   r   r     s*        zH         r   r   c                   "    e Zd Zej        Zd ZdS )Discardc                     t          | j                  }|                    |           |j        | _        |j        | _        d S r   )rS   r`   r\   r<   r^   )r   rU   r`   s      r   rh   zDiscard.run  s=    TY''		%k+r   N)r   r   r   r   r   r3   rh   r   r   r   r   r     s*        {H, , , , ,r   r   c                   "    e Zd Zej        Zd ZdS )re   c                 b    | j         D ]&}t          |          }|                    |           'd S r   )r   rS   rh   )r   rU   stmts      r   rh   zStmt.run  s;    J 	 	D &&DHHUOOOO	 	r   N)r   r   r   r   re   r3   rh   r   r   r   re   re     s*        xH    r   re   c                     | j                                         }|rd|z   }nd}t          j                            | j        j        d| j        |d           d S )Nz, in:  : 
)r   rj   r   stdoutwriter   r   r   )er^   s     r   report_failurer     sa    &))++K ,JQU^^^QWWkkkJKKKKKr   c                 B   |3t          j        d          }t          j                            |          }t          | d          }t          |t          j                  sJ t          |j
                  }	 |                    |           |                    |j                  s6t           j                            d|                                z             d S d S # t"          $ r  t$          $ r, t          j                    d         }t)          |           Y d S w xY w)Nr?   r\   zassertion failed: %s
)r   	_getframepycodeFramer   rC   r   rX   rS   r   r\   rp   r<   stderrr   rj   r]   r	   r   r   )srU   r`   r   r   s        r   checkr     s#   }a  e$$FDdCN+++++##D	Q		% }}T[)) 	QJ58M8M8O8OOPPPPP	Q 	Q       LNN1qs   7C <DDFc                    t          t          | d          j                  }t          |t          j                  rt          j                            |          }	 |	                    |           n\# t          $ r+ t          j                    d         }t          |          cY S t          $ r   dd l}|                                 Y nxY w|rdS d S )Nexecr?   r   z(assertion failed, but when it was re-run for printing intermediate values, it did not fail.  Suggestions: compute assert expression before the assert or use --nomagic))rS   r   r   rC   types	FrameTyper   r   r   rh   r	   r   r   
getfailurer]   	traceback	print_exc)rr   rU   should_failmoduler   r   s         r   	interpretr     s    500566F%)) %e$$	

5   LNN1!}}    P P ts   A3 32C'#Cc                 P   t          | t                    rt          j                            |           } | j        d         }t          |j                                                  }t          ||j
        d          }t          |t                    st          d|          |S )Nr   T)r   zinterpret returned non-string )rC   rD   r   r   ExceptionInfor   str	statementstripr   rU   	TypeError)excinfor   rr   xs       r   getmsgr     s    '5!! 1'''00
 
	2	B$$&&F&"(555Aa CiaaABBBHr   c                 D   | j                                         }t          | j                  rB|                    d          }|dxx         d| j        z  cc<   d                    |          }| j        j        d|}|                    d          r
|dd          }|S )Nr   r   z  << r   zAssertionError: assert    )	r   rj   r   r   splitr   r   r   r   )r   r^   linestexts       r   r   r     s    &))++K
17|| '!!$''a**ii&&u~~~{{3D011 BCCyKr   c                 R   |3t          j        d          }t          j                            |          }t          t          | d          j                  }	 |                    |           d S # t          $ r, t          j
                    d         }t          |           Y d S w xY w)Nr?   r   )r   r   r   r   r   rS   r   r   rh   r	   r   r   )r   rU   r   r   s       r   rh   rh     s    }a  e$$5F++011F

5   LNN1qs   A0 02B&%B&__main__c                      dS )N   r   r   r   r   fr         qr   c                      dS )N   r   r   r   r   gr    r   r   c                     dS )Nneverr   )r   s    r   hr    s    wr   zf() * g() == 5znot f()znot (f() and g() or 0)z
f() == g()   zi == f()zlen(f()) == 0zisinstance(2+3+4, float)zx = izx == 5zassert not f(), 'oops'za, b, c = 1, 2za, b, c = f()zmax([f(),g()]) == 4z'hello'[g()] == 'h'z'guk%d' % h(f())r   )F)7r   r   r7   compilerr   r   r   py._code.assertionr   r   r   builtin_sysexr]   r	   r   r   rB   rS   rl   r|   r   r   	keepaliveNotInvertitemsr   r   r   r   AddSubMulDivModPowerr   r   r   r   r   r   re   r   r   r   r   r   rh   r   r   r  r  ir   r   r   <module>r     s   				         * * * * * * * * * * I I I I I I I I 
!       
LF LF LF LF LF6 LF LF LF^  #5 #5 #5 #5 #5D #5 #5 #5L") ") ") ") ")= ") ") ")H    m   4B B B B B- B B BA A A A A A A A  	G&J% egg! !Hj
$ $ $ $ $] $ $ $  Z     G7G7G7G7G7I8 egg" "Hj$ $ $ $ $m $ $ $( [!!!!>L >L >L >L >L} >L >L >L@L L L L Lm L L L<$ $ $ $ $] $ $ $*         ]      (, , , , ,m , , ,    =   L L LQ Q Q Q.   ,  	 	 		 	 	 	 z      	E
	E)	E
"###	E,	A	E*	E/	E
$%%%CLLL	E(OOOC !!!CC	E
   	E
   C5 r   