
    ;eJj                        d dl Z d dlmZ 	 d dlZn# e$ r dZY nw xY wd dlZd dlZd dlZd dlZd dl	Z	 G d de
          Z G d de j                  Ze G d de j                              Z G d	 d
e j                  Z G d de          Z G d de          Z G d de          Z G d de          Zd Zd Z G d d          Z e            Z e            Z G d de j                  ZdZdZd Zd Z G d de j                  Z G d d           Z e G d! d"e j                              Z!e"d#k    r e j#                     dS dS )$    N)cpython_onlyc                       e Zd Zd Zd ZdS )BadStrc                     dS )NT )selfothers     %/usr/lib/python3.11/test/test_call.py__eq__zBadStr.__eq__   s    t    c                 <    t                               |           dz  S )N   )str__hash__r   s    r
   r   zBadStr.__hash__   s    ||D!!A%%r   N)__name__
__module____qualname__r   r   r   r   r
   r   r      s2          & & & & &r   r   c                       e Zd Zd Zd ZdS )FunctionCallsc                 T   t          j        ddg          }|                    d           t          |                                          }d } |di |}|                     |t                     |                     t          |                                          |           d S )N)a   )b   r   c                      | S Nr   )kws    r
   fnz+FunctionCalls.test_kwargs_order.<locals>.fn   s    Ir   r   )collectionsOrderedDictmove_to_endlistitemsassertIsInstancedictassertEqual)r   odexpectedr   ress        r
   test_kwargs_orderzFunctionCalls.test_kwargs_order   s    $h%9::
s

##	 	 	 bhh2hhc4(((ciikk**H55555r   c                 h    d }t          d          D ]}	  |d            # t          $ r Y w xY wd S )Nc                      d S r   r   r   r   r
   fzBFunctionCalls.test_frames_are_popped_after_failed_calls.<locals>.f(   s    Dr   i  )range	TypeError)r   r.   _s      r
   )test_frames_are_popped_after_failed_callsz7FunctionCalls.test_frames_are_popped_after_failed_calls%   sd    	 	 	t 	 	A$   	 	s   "
//N)r   r   r   r+   r2   r   r   r
   r   r      s2        6 6 6	 	 	 	 	r   r   c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d  Z"d! Z#d" Z$d# Z%d$S )%CFunctionCallsErrorMessagesc                 L    d}|                      t          |i j                   d S )Nz7__contains__\(\) takes exactly one argument \(0 given\)assertRaisesRegexr0   __contains__r   msgs     r
   test_varargs0z)CFunctionCallsErrorMessages.test_varargs05   s'    Hy#r?????r   c                 P    d}|                      t          |i j        dd           d S )Nz7__contains__\(\) takes exactly one argument \(2 given\)r   r   r6   r9   s     r
   test_varargs2z)CFunctionCallsErrorMessages.test_varargs29   s+    Hy#r1EEEEEr   c                 \    d}|                      t          |t          j        ddd           d S )Nz@^from_bytes\(\) takes at most 2 positional arguments \(3 given\)   alittleF)r7   r0   int
from_bytesr9   s     r
   test_varargs3z)CFunctionCallsErrorMessages.test_varargs3=   s-    Qy#s~tXuUUUUUr   c                     d}|                      t          |i j                   d}|                      t          |i j                   d S )Nz'get expected at least 1 argument, got 0zexpected 1 argument, got 0)r7   r0   get__delattr__r9   s     r
   test_varargs1minz,CFunctionCallsErrorMessages.test_varargs1minA   sF    8y#rv666+y#r~>>>>>r   c                 L    d}|                      t          |t                     d S )Nz,getattr expected at least 2 arguments, got 0r7   r0   getattrr9   s     r
   test_varargs2minz,CFunctionCallsErrorMessages.test_varargs2minH   s%    =y#w77777r   c                 P    d}|                      t          |t          dd           d S )Nz(input expected at most 1 argument, got 2r   r   )r7   r0   inputr9   s     r
   test_varargs1maxz,CFunctionCallsErrorMessages.test_varargs1maxL   s)    9y#ua;;;;;r   c                 R    d}|                      t          |i j        ddd           d S )Nz'get expected at most 2 arguments, got 3r   r   r   )r7   r0   rE   r9   s     r
   test_varargs2maxz,CFunctionCallsErrorMessages.test_varargs2maxP   s-    8y#rvq!Q?????r   c                 P    d}|                      t          |i j        d           d S )N+__contains__\(\) takes no keyword argumentsr   xr6   r9   s     r
   test_varargs1_kwz,CFunctionCallsErrorMessages.test_varargs1_kwT   s,    <y#r!DDDDDr   c                 R    d}|                      t          |i j        dd           d S )NrR   r   rT   yr6   r9   s     r
   test_varargs2_kwz,CFunctionCallsErrorMessages.test_varargs2_kwX   s.    <y#r!qIIIIIr   c                 P    d}|                      t          |t          d           d S )Nz#bool\(\) takes no keyword argumentsr   rS   )r7   r0   boolr9   s     r
   test_varargs3_kwz,CFunctionCallsErrorMessages.test_varargs3_kw\   s*    4y#tq99999r   c                 P    d}|                      t          |g j        d           d S )Nz-^list[.]index\(\) takes no keyword arguments$r   rS   )r7   r0   indexr9   s     r
   test_varargs4_kwz,CFunctionCallsErrorMessages.test_varargs4_kw`   s,    >y#rx1=====r   c                 P    d}|                      t          |t          d           d S )Nz(^hasattr\(\) takes no keyword arguments$r   rS   )r7   r0   hasattrr9   s     r
   test_varargs5_kwz,CFunctionCallsErrorMessages.test_varargs5_kwd   *    9y#w!<<<<<r   c                 P    d}|                      t          |t          d           d S )Nz(^getattr\(\) takes no keyword arguments$r   rS   rI   r9   s     r
   test_varargs6_kwz,CFunctionCallsErrorMessages.test_varargs6_kwh   rc   r   c                 P    d}|                      t          |t          d           d S )Nz%^next\(\) takes no keyword arguments$r   rS   )r7   r0   nextr9   s     r
   test_varargs7_kwz,CFunctionCallsErrorMessages.test_varargs7_kwl   s*    6y#tq99999r   c                 Z    d}|                      t          |t          j        d           d S )Nz/^_struct[.]pack\(\) takes no keyword arguments$r   rS   )r7   r0   structpackr9   s     r
   test_varargs8_kwz,CFunctionCallsErrorMessages.test_varargs8_kwp   s,    @y#v{a@@@@@r   c                 Z    d}|                      t          |t          j        d           d S )Nz4^_struct[.]pack_into\(\) takes no keyword arguments$r   rS   )r7   r0   rj   	pack_intor9   s     r
   test_varargs9_kwz,CFunctionCallsErrorMessages.test_varargs9_kwt   s-    Ey#v/?1EEEEEr   c                 r    d}|                      t          |t          j                    j        d           d S )Nz.^deque[.]index\(\) takes no keyword arguments$r   rS   )r7   r0   r    dequer^   r9   s     r
   test_varargs10_kwz-CFunctionCallsErrorMessages.test_varargs10_kwx   s6    ?y#{/@/B/B/HANNNNNr   c                     d}|                      t          |t          j        j        t          j        d          d           d S )Nz.^Struct[.]pack\(\) takes no keyword arguments$ r   rS   )r7   r0   rj   Structrk   r9   s     r
   test_varargs11_kwz-CFunctionCallsErrorMessages.test_varargs11_kw|   s=    ?y#v}/A6=QSCTCTXYZZZZZr   c                 Z    d}|                      t          |t          t                     d S )Nz-^staticmethod\(\) takes no keyword arguments$func)r7   r0   staticmethodidr9   s     r
   test_varargs12_kwz-CFunctionCallsErrorMessages.test_varargs12_kw   s*    >y#|"EEEEEr   c                 Z    d}|                      t          |t          t                     d S )Nz,^classmethod\(\) takes no keyword arguments$rx   )r7   r0   classmethodr{   r9   s     r
   test_varargs13_kwz-CFunctionCallsErrorMessages.test_varargs13_kw   s*    =y#{DDDDDr   c                 ^    d}|                      t          |t          j        ddd           d S )Nz:^product\(\) takes at most 1 keyword argument \(2 given\)$r   r   r   )repeatfoo)r7   r0   	itertoolsproductr9   s     r
   test_varargs14_kwz-CFunctionCallsErrorMessages.test_varargs14_kw   sC    Ky#(0!A1 	 	F 	F 	F 	F 	Fr   c           	      V    d}|                      t          |t          dddd           d S )Nz?^ImportError\(\) takes at most 2 keyword arguments \(3 given\)$r   r   r   r   )namepathr   )r7   r0   ImportErrorr9   s     r
   test_varargs15_kwz-CFunctionCallsErrorMessages.test_varargs15_kw   sB    Py#*AAA1 	 	F 	F 	F 	F 	Fr   c           	      V    d}|                      t          |t          dddd           d S )Nz7^min\(\) takes at most 2 keyword arguments \(3 given\)$r   r   r   r   )defaultkeyr   )r7   r0   minr9   s     r
   test_varargs16_kwz-CFunctionCallsErrorMessages.test_varargs16_kw   sB    Hy#"AqaQ 	 	@ 	@ 	@ 	@ 	@r   c                 Z    d}|                      t          |t          dddddd	  	         d S )	Nz3'foo' is an invalid keyword argument for print\(\)$r   r   r   r         )sependfileflushr   )r7   r0   printr9   s     r
   test_varargs17_kwz-CFunctionCallsErrorMessages.test_varargs17_kw   sF    Dy#$aQAAQA 	 	O 	O 	O 	O 	Or   c                     d}|                      t          |          5  t          di t          d          di d d d            d S # 1 swxY w Y   d S )Nz'invalid keyword argument for print\(\)$r   r   r   ,)r   r   )r7   r0   r   r   r9   s     r
   test_varargs18_kwz-CFunctionCallsErrorMessages.test_varargs18_kw   s    8##Is33 	0 	0//6%==#.///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0   AAAc                     d}|                      t          |          5  t          di t          d          di d d d            d S # 1 swxY w Y   d S )Nz'invalid keyword argument for round\(\)$      ?r   r   )r   )r7   r0   roundr   r9   s     r
   test_varargs19_kwz-CFunctionCallsErrorMessages.test_varargs19_kw   s    8##Is33 	. 	.--6%==!,---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.r   c                 N    d}|                      t          |i j        d           d S )Nz'keys\(\) takes no arguments \(1 given\)r   r7   r0   keysr9   s     r
   test_oldargs0_1z+CFunctionCallsErrorMessages.test_oldargs0_1   s)    8y#rw:::::r   c                 P    d}|                      t          |i j        dd           d S )Nz'keys\(\) takes no arguments \(2 given\)r   r   r   r9   s     r
   test_oldargs0_2z+CFunctionCallsErrorMessages.test_oldargs0_2   s+    8y#rw1=====r   c                 P    d}|                      t          |i j        d           d S )N#keys\(\) takes no keyword argumentsr   rS   r   r9   s     r
   test_oldargs0_1_kwz.CFunctionCallsErrorMessages.test_oldargs0_1_kw   s,    4y#rw!<<<<<r   c                 R    d}|                      t          |i j        dd           d S )Nr   r   rW   r   r9   s     r
   test_oldargs0_2_kwz.CFunctionCallsErrorMessages.test_oldargs0_2_kw   s.    4y#rw!qAAAAAr   c                 L    d}|                      t          |g j                   d S )Nz0count\(\) takes exactly one argument \(0 given\)r7   r0   countr9   s     r
   test_oldargs1_0z+CFunctionCallsErrorMessages.test_oldargs1_0   s'    Ay#rx88888r   c                 P    d}|                      t          |g j        dd           d S )Nz0count\(\) takes exactly one argument \(2 given\)r   r   r   r9   s     r
   test_oldargs1_2z+CFunctionCallsErrorMessages.test_oldargs1_2   s+    Ay#rxA>>>>>r   c                 P    d}|                      t          |g j        d           d S N$count\(\) takes no keyword argumentsr   rS   r   r9   s     r
   test_oldargs1_0_kwz.CFunctionCallsErrorMessages.test_oldargs1_0_kw   s,    5y#rx1=====r   c                 R    d}|                      t          |g j        i d           d S r   r   r9   s     r
   test_oldargs1_1_kwz.CFunctionCallsErrorMessages.test_oldargs1_1_kw   s.    5y#rxqAAAAAr   c                 R    d}|                      t          |g j        dd           d S )Nr   r   rW   r   r9   s     r
   test_oldargs1_2_kwz.CFunctionCallsErrorMessages.test_oldargs1_2_kw   s.    5y#rx1BBBBBr   N)&r   r   r   r;   r=   rC   rG   rK   rN   rP   rU   rY   r\   r_   rb   re   rh   rl   ro   rr   rv   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r
   r4   r4   2   s\       @ @ @F F FV V V? ? ?8 8 8< < <@ @ @E E EJ J J: : :> > >= = == = =: : :A A AF F FO O O[ [ [F F FE E EF F F
F F F
@ @ @
O O O
0 0 0. . .; ; ;> > >= = =B B B9 9 9? ? ?> > >B B BC C C C Cr   r4   c                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )TestCallingConventionsa  Test calling using various C calling conventions (METH_*) from Python

    Subclasses test several kinds of functions (module-level, methods,
    class methods static methods) using these attributes:
      obj: the object that contains tested functions (as attributes)
      expected_self: expected "self" argument to the C function

    The base class tests module-level functions.
    c                 ,    t           x| _        | _        d S r   )	_testcapiobjexpected_selfr   s    r
   setUpzTestCallingConventions.setUp   s    (114%%%r   c                 t    |                      | j                            ddd          | j        df           d S Nr   r   r   r   r   r   r'   r   meth_varargsr   r   s    r
   test_varargsz#TestCallingConventions.test_varargs   sF    H!!!Q**+	
 	
 	
 	
 	
r   c                 Z    |                       | j        j        d | j        df           d S Nr   r   r   s    r
   test_varargs_extz'TestCallingConventions.test_varargs_ext   s>    !DH!9-+	
 	
 	
 	
 	
r   c                 J     d}                      t          | fd           d S )Nz+meth_varargs\(\) takes no keyword argumentsc                  :     j                             d          S Nr   )k)r   r   r   s   r
   <lambda>z>TestCallingConventions.test_varargs_error_kw.<locals>.<lambda>   s    DH$9$9A$9$>$> r   r7   r0   r9   s   ` r
   test_varargs_error_kwz,TestCallingConventions.test_varargs_error_kw   s;    <s>>>>	
 	
 	
 	
 	
r   c                     |                      | j                            dddd          | j        ddddf           d S Nr   r   r   r   r   r   r   r   r'   r   meth_varargs_keywordsr   r   s    r
   test_varargs_keywordsz,TestCallingConventions.test_varargs_keywords   sU    H**1a1*::qq)9)9:	
 	
 	
 	
 	
r   c           	      r    |                       | j        j        ddgi ddd| j        ddddf           d S r   r   r   s    r
   test_varargs_keywords_extz0TestCallingConventions.test_varargs_keywords_ext   s\    *DH*QFGAA6F6FGGqq)9)9:	
 	
 	
 	
 	
r   c                 p    |                      | j                            d          | j        df           d S Nr   r'   r   meth_or   r   s    r
   test_ozTestCallingConventions.test_o   s4    ++d.@!-DEEEEEr   c                 \    |                       | j        j        dg | j        df           d S r   r   r   s    r
   
test_o_extz!TestCallingConventions.test_o_ext   s3    1#.1CQ0GHHHHHr   c                 V    d}|                      t          || j        j                   d S )Nz1meth_o\(\) takes exactly one argument \(0 given\))r7   r0   r   r   r9   s     r
   test_o_error_no_argz*TestCallingConventions.test_o_error_no_arg   s)    By#tx?????r   c                 J     d}                      t          | fd           d S )Nz1meth_o\(\) takes exactly one argument \(2 given\)c                  :     j                             dd          S Nr   r   r   r   r   s   r
   r   z>TestCallingConventions.test_o_error_two_args.<locals>.<lambda>  s    DHOOAq$9$9 r   r   r9   s   ` r
   test_o_error_two_argsz,TestCallingConventions.test_o_error_two_args  s;    Bs9999	
 	
 	
 	
 	
r   c                 J     d}                      t          | fd           d S )Nz1meth_o\(\) takes exactly one argument \(3 given\)c                  "      j         j        d S r   r   r   s   r
   r   z9TestCallingConventions.test_o_error_ext.<locals>.<lambda>  s    ODHOY$? r   r   r9   s   ` r
   test_o_error_extz'TestCallingConventions.test_o_error_ext
  s;    Bs????	
 	
 	
 	
 	
r   c                 J     d}                      t          | fd           d S )N%meth_o\(\) takes no keyword argumentsc                  :     j                             d          S r   r   r   s   r
   r   z8TestCallingConventions.test_o_error_kw.<locals>.<lambda>      DHOOaO$8$8 r   r   r9   s   ` r
   test_o_error_kwz&TestCallingConventions.test_o_error_kw  ;    6s8888	
 	
 	
 	
 	
r   c                 J     d}                      t          | fd           d S )Nr   c                  :     j                             d          S r   r   r   s   r
   r   z<TestCallingConventions.test_o_error_arg_kw.<locals>.<lambda>  r   r   r   r9   s   ` r
   test_o_error_arg_kwz*TestCallingConventions.test_o_error_arg_kw  r   r   c                 j    |                      | j                                        | j                   d S r   r'   r   meth_noargsr   r   s    r
   test_noargsz"TestCallingConventions.test_noargs  s/    --//1CDDDDDr   c                 V    |                       | j        j        g  | j                   d S r   r   r   s    r
   test_noargs_extz&TestCallingConventions.test_noargs_ext  s.    --r2D4FGGGGGr   c                 J     d}                      t          | fd           d S )Nz.meth_noargs\(\) takes no arguments \(1 given\)c                  8     j                             d          S r   r   r   r   s   r
   r   z>TestCallingConventions.test_noargs_error_arg.<locals>.<lambda>%  s    DH$8$8$;$; r   r   r9   s   ` r
   test_noargs_error_argz,TestCallingConventions.test_noargs_error_arg"  s;    ?s;;;;	
 	
 	
 	
 	
r   c                 J     d}                      t          | fd           d S )Nz.meth_noargs\(\) takes no arguments \(2 given\)c                  :     j                             dd          S r   r   r   s   r
   r   z?TestCallingConventions.test_noargs_error_arg2.<locals>.<lambda>+  s    DH$8$8A$>$> r   r   r9   s   ` r
   test_noargs_error_arg2z-TestCallingConventions.test_noargs_error_arg2(  s;    ?s>>>>	
 	
 	
 	
 	
r   c                 J     d}                      t          | fd           d S )Nz.meth_noargs\(\) takes no arguments \(3 given\)c                  "      j         j        d S r   r   r   s   r
   r   z>TestCallingConventions.test_noargs_error_ext.<locals>.<lambda>1  s    $8DH$8)$D r   r   r9   s   ` r
   test_noargs_error_extz,TestCallingConventions.test_noargs_error_ext.  s;    ?sDDDD	
 	
 	
 	
 	
r   c                 J     d}                      t          | fd           d S )Nz*meth_noargs\(\) takes no keyword argumentsc                  :     j                             d          S r   r   r   s   r
   r   z=TestCallingConventions.test_noargs_error_kw.<locals>.<lambda>7  s    DH$8$81$8$=$= r   r   r9   s   ` r
   test_noargs_error_kwz+TestCallingConventions.test_noargs_error_kw4  s;    ;s====	
 	
 	
 	
 	
r   c                 t    |                      | j                            ddd          | j        df           d S r   r'   r   meth_fastcallr   r   s    r
   test_fastcallz$TestCallingConventions.test_fastcall:  sF    H""1a+++	
 	
 	
 	
 	
r   c                 Z    |                       | j        j        d | j        df           d S r   r  r   s    r
   test_fastcall_extz(TestCallingConventions.test_fastcall_ext@  s>    "DH"I.+	
 	
 	
 	
 	
r   c                 J     d}                      t          | fd           d S )Nz,meth_fastcall\(\) takes no keyword argumentsc                  :     j                             d          S r   )r   r	  r   s   r
   r   z?TestCallingConventions.test_fastcall_error_kw.<locals>.<lambda>I  s    DH$:$:Q$:$?$? r   r   r9   s   ` r
   test_fastcall_error_kwz-TestCallingConventions.test_fastcall_error_kwF  s;    =s????	
 	
 	
 	
 	
r   c                     |                      | j                            dddd          | j        ddddf           d S r   r'   r   meth_fastcall_keywordsr   r   s    r
   test_fastcall_keywordsz-TestCallingConventions.test_fastcall_keywordsL  sU    H++AqA+;;qq)9)9:	
 	
 	
 	
 	
r   c           	      n    |                       | j        j        di ddd| j        ddddf           d S )Nr   r   r   r   r  r   s    r
   test_fastcall_keywords_extz1TestCallingConventions.test_fastcall_keywords_extR  sX    +DH+VHQQ7G7GHHqq)9)9:	
 	
 	
 	
 	
r   N)r   r   r   __doc__r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r
  r  r  r  r  r   r   r
   r   r      s        2 2 2
 
 

 
 

 
 

 
 

 
 
F F FI I I@ @ @
 
 

 
 

 
 

 
 
E E EH H H
 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 
 
 
r   r   c                       e Zd ZdZd ZdS )TestCallingConventionsInstancez?Test calling instance methods using various calling conventionsc                 D    t          j                    x| _        | _        d S r   )r   MethInstancer   r   r   s    r
   r   z$TestCallingConventionsInstance.setUp\  s     (1(>(@(@@4%%%r   Nr   r   r   r  r   r   r   r
   r  r  Y  s.        IIA A A A Ar   r  c                       e Zd ZdZd ZdS )TestCallingConventionsClassz<Test calling class methods using various calling conventionsc                 6    t           j        x| _        | _        d S r   r   	MethClassr   r   r   s    r
   r   z!TestCallingConventionsClass.setUpc  s    (1(;;4%%%r   Nr  r   r   r
   r  r  `  s)        FF< < < < <r   r  c                       e Zd ZdZd ZdS )#TestCallingConventionsClassInstancez&Test calling class methods on instancec                 X    t          j                    | _        t           j        | _        d S r   r  r   s    r
   r   z)TestCallingConventionsClassInstance.setUpj  s#    &((&0r   Nr  r   r   r
   r"  r"  g  s)        001 1 1 1 1r   r"  c                       e Zd ZdZd ZdS )TestCallingConventionsStaticz=Test calling static methods using various calling conventionsc                 D    t          j                    | _        d | _        d S r   )r   
MethStaticr   r   r   s    r
   r   z"TestCallingConventionsStatic.setUpr  s     '))!r   Nr  r   r   r
   r%  r%  o  s)        GG" " " " "r   r%  c                 
    | |gS r   r   arg1arg2s     r
   pyfuncr,  w  s    $<r   c                      dS Nnoargr   r   r   r
   pyfunc_noargr0  {  s    7r   c                   F    e Zd Zd Zd Zed             Zed             ZdS )PythonClassc                 
    ||gS r   r   )r   r*  r+  s      r
   methodzPythonClass.method  s    d|r   c                     dS r.  r   r   s    r
   method_noargzPythonClass.method_noarg  s    wr   c                     dS )Nr~   r   )clss    r
   class_methodzPythonClass.class_method  s    }r   c                      dS )Nrz   r   r   r   r
   static_methodzPythonClass.static_method  s    ~r   N)	r   r   r   r4  r6  r~   r9  rz   r;  r   r   r
   r2  r2    sh               [   \  r   r2  c                   l   e Zd ZdZedddgfeddfej        ddfej        ddfe	j
        dddgfe	j        ddfe	j        ddfe	j        ddfgZed	d
diddgfeddddddgfe	j
        d	d
diddgfe	j
        ddddddgfgZ ej                    Zeefeefej        ej        f ej                    ej        fej        dffD ]\  ZZe                    ej        dedffej        dedeffej        dedffej        dedffej        dedeffej        dedeffej        defej        dedffg           e                    ej        dddiedddiffej        dddiedddiffej        di edeffej        dddiedddiffej        dddiedddiffej        di edeffg           d Zd Zd Zd Z d Z!dS )FastCallTestsz0Test calling using various callables from C
    r   r   r   r   r/  r~   rz   )r   r+  r)  N){   r>  rT   rX   c                     t          |t                    r0|d         t          u r!|d         i d fv rg |d d         |d         R }|                     ||           d S )N)
isinstancetupleNULL_OR_EMPTYr'   )r   resultr)   s      r
   check_resultzFastCallTests.check_result  so    h&& 	88B<=+H+Hbzb$Z''7Xcrc]7F2J77*****r   c                 0   | j         D ]\  }}}|                     ||          5  t          j        ||          }|                     ||           |s+t          j        |d           }|                     ||           d d d            n# 1 swxY w Y   d S )Nry   args)CALLS_POSARGSsubTestr   pyobject_fastcallrE  )r   ry   rH  r)   rD  s        r
   r
  zFastCallTests.test_fastcall  s     %)$6 	8 	8 D$4d33 8 8"4T4@@!!&(333 8&8tDDF%%fh7778 8 8 8 8 8 8 8 8 8 8 8 8 8 8	8 	8s   AB

B	B	c                 
   | j         D ]\  }}}|                     ||          5  t          j        ||d           }|                     ||           |s,t          j        |d d           }|                     ||           d d d            n# 1 swxY w Y   | j        D ]c\  }}}}|                     |||          5  t          j        |||          }|                     ||           d d d            n# 1 swxY w Y   dd S )NrG  ry   rH  kwargs)rI  rJ  r   pyobject_fastcalldictrE  CALLS_KWARGS)r   ry   rH  r)   rD  rN  s         r
   test_vectorcall_dictz"FastCallTests.test_vectorcall_dict  s    %)$6 		8 		8 D$4d33 8 8"8tTJJ!!&(333 8&<T4NNF%%fh7778 8 8 8 8 8 8 8 8 8 8 8 8 8 8 -1,= 	4 	4(D$4d6BB 4 4"8tVLL!!&(3334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	4s$   ABB	B	>-C77C;	>C;	c                 D   | j         D ]\  }}}|                     ||          5  t          j        ||d           }|                     ||           t          j        ||d          }|                     ||           |sXt          j        |d d           }|                     ||           t          j        |d d          }|                     ||           d d d            n# 1 swxY w Y   | j        D ]\  }}}}|                     |||          5  t          |                                          }|t          |                                          z   }t          j        |||          }|                     ||           d d d            n# 1 swxY w Y   d S )NrG  r   rM  )	rI  rJ  r   pyobject_vectorcallrE  rP  rB  r   values)r   ry   rH  r)   rD  rN  kwnamess          r
   test_vectorcallzFastCallTests.test_vectorcall	  s+    %)$6 	8 	8 D$4d33 8 8"6tT4HH!!&(333 #6tT2FF!!&(333 8&:4tLLF%%fh777 ':4rJJF%%fh777!8 8 8 8 8 8 8 8 8 8 8 8 8 8 8$ -1,= 	4 	4(D$4d6BB 4 4..eFMMOO444"6tT7KK!!&(333	4 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	4s%   B3C$$C(	+C(	A2FF	F	c                 r     G d d          } | |                      }t          ddd|fi |j         d S )Nc                        e Zd ZdgZd Zd ZdS )>FastCallTests.test_fastcall_clearing_dict.<locals>.IntWithDictrN  c                     || _         d S r   )rN  )r   rN  s     r
   __init__zGFastCallTests.test_fastcall_clearing_dict.<locals>.IntWithDict.__init__+  s    $r   c                 ^    | j                                          t          j                     dS )Nr   )rN  cleargccollectr   s    r
   	__index__zHFastCallTests.test_fastcall_clearing_dict.<locals>.IntWithDict.__index__-  s&    !!###
qr   N)r   r   r   	__slots__r[  r`  r   r   r
   IntWithDictrY  )  s9        !
I% % %    r   rb  )optimizepassrt   exec)compilerN  )r   rb  rT   s      r
   test_fastcall_clearing_dictz)FastCallTests.test_fastcall_clearing_dict&  sj    	 	 	 	 	 	 	 	 K/// 	FA2222222r   )"r   r   r   r  r,  r0  r2  r9  r;  PYTHON_INSTANCEr4  r6  rI  rP  r   r  	_instancer   r'  r   r   extendr   r   rC  r	  r  r   r   rE  r
  rQ  rV  rg  r   r   r
   r=  r=    sK         
!Q  
r7# 
	!2}5		"B7 
	!Q0		%r73		%r=9		&N;#M6 
{QF+	a++aV4 
	{QF;		a%;%;aVDL '	&((I	I	I		i12					 34		t$ " "] 	vv'>?&>@(?@]B$78'>@']B68_b-0Z=#"67
 	 	 	 	&c
]FS#J$GI&S#JS#J ?A&]FMBD'c
]FS#J$GI'S#JS#J ?A']FMBD
 	 	 	 	+ + +8 8 84 4 4&4 4 4:3 3 3 3 3r   r=  i   i   c                     | S zsome docr   r   s    r
   testfunctionrm  <      Kr   c                    | S rl  r   )r   r   s     r
   testfunction_kwrp  A  rn  r   c                   &    e Zd Zd Zd Zd Zd ZdS )
TestPEP590c                    dd l } |                    d          t                    }|                     t	          t
                    j        t          z             |                     t	          t          j
                  j        t          z             |                     t	          t          j                  j        t          z             |                     t	          t                    j        t          z             |                     t	          |          j        t          z             |                     t          j        j        t          z             |                     t          j        j        t          z             |                     t          j        j        t          z              G d dt          j                  }|                     |j        t          z             d S )Nr   r   c                       e Zd ZdS )DTestPEP590.test_method_descriptor_flag.<locals>.MethodDescriptorHeapNr   r   r   r   r   r
   MethodDescriptorHeapru  W          Dr   rw  )	functools	lru_cacherm  assertFalsetyperepr	__flags__Py_TPFLAGS_METHOD_DESCRIPTOR
assertTruer#   append__add__r   MethodDescriptorBaseMethodDescriptorDerivedMethodDescriptorNopGet)r   ry  cachedrw  s       r
   test_method_descriptor_flagz&TestPEP590.test_method_descriptor_flagH  s   '$$Q''55d-0LLMMMT[))36RRSSST\**47SSTTT\**47SSTTTV.1MMNNN	6@C__```	9CFbbccc9CFbbccc	 	 	 	 	9#A 	 	 	-7:VVWWWWWr   c                    |                      t          j        j        t          z             |                      t          j        j        t          z             |                     t          j        j        t          z             |                      t          j        j        t          z              G d dt          j                  }|                     |j        t          z             d S )Nc                       e Zd ZdS )=TestPEP590.test_vectorcall_flag.<locals>.MethodDescriptorHeapNrv  r   r   r
   rw  r  b  rx  r   rw  )	r  r   r  r~  Py_TPFLAGS_HAVE_VECTORCALLr  r{  r  MethodDescriptor2)r   rw  s     r
   test_vectorcall_flagzTestPEP590.test_vectorcall_flag[  s    	6@C]]^^^	9CF``aaa9CF``aaa	3=@ZZ[[[	 	 	 	 	9#A 	 	 	-7:TTUUUUUr   c                     t          t          d                    }t          j                    }|                      || |           d S )Nr   )rB  r/   r   r  assertIs)r   rH  r.   s      r
   test_vectorcall_overridez#TestPEP590.test_vectorcall_overridef  sC     U1XX,..aah%%%%%r   c                 `   t           t          d          fi dft          j        g dfi d fg j        di d ft          dgfddidft
          di dft          ddd idft          j                    di d	ft          j	                    di d	ft          j
                    di d
fg	}ddlmm} ddlm} ddlm} fd}|D ]\  }}}}	|                     t%          |                    5  |s |                     |	 |||                     |                     |	 ||||                     d d d            n# 1 swxY w Y    G d dt          j                  }
 G d dt          j                  } G d d          } G d d|t          j                  }|t(          j        i fdd	id fi j        i fdd	id f |
            di d	f |            di df |            di d	fgz  }|D ]L\  }}}}	|                     t%          |                    5  |dd          } |||d                   } ||          }|sl|                     |	 ||            |                     |	 ||d                      |                     |	 ||            |                     |	 ||            |                     |	 ||i |           |                     |	 ||||                     |                     |	 ||i |           |                     |	 ||i |           d d d            n# 1 swxY w Y   Nd S )N*   r   )r   $   start   )r  r   TF)rS  pyvectorcall_call)
MethodType)partialc                 n    g ||                                 R }t          |          } | ||          S r   )rT  rB  )ry   rH  rN  rU  rS  s       r
   
vectorcallz.TestPEP590.test_vectorcall.<locals>.vectorcall  s=    *D*6==??**DFmmG&&tT7;;;r   c                       e Zd ZdS )8TestPEP590.test_vectorcall.<locals>.MethodDescriptorHeapNrv  r   r   r
   rw  r    rx  r   rw  c                       e Zd Zd ZdS )>TestPEP590.test_vectorcall.<locals>.MethodDescriptorOverriddenc                     dS )Nnewr   )r   ns     r
   __call__zGTestPEP590.test_vectorcall.<locals>.MethodDescriptorOverridden.__call__  s    ur   N)r   r   r   r  r   r   r
   MethodDescriptorOverriddenr    s#            r   r  c                        e Zd Z fdZ xZS )-TestPEP590.test_vectorcall.<locals>.SuperBasec                 0     t                      j        | S r   superr  r   rH  	__class__s     r
   r  z6TestPEP590.test_vectorcall.<locals>.SuperBase.__call__      'uww'..r   r   r   r   r  __classcell__r  s   @r
   	SuperBaser    8        / / / / / / / / /r   r  c                        e Zd Z fdZ xZS )9TestPEP590.test_vectorcall.<locals>.MethodDescriptorSuperc                 0     t                      j        | S r   r  r  s     r
   r  zBTestPEP590.test_vectorcall.<locals>.MethodDescriptorSuper.__call__  r  r   r  r  s   @r
   MethodDescriptorSuperr    r  r   r  r   r  r   )lenr/   r#   r  sumrm  rp  r   r  r  r  rS  r  typesr  ry  r  rJ  r   r'   r&   update)r   callsr  r  r  r  ry   rH  rN  r)   rw  r  r  r  args1methwrappedrS  s                    @r
   rV  zTestPEP590.test_vectorcallp  s
    b		|R,+AwD1)T2t,wR0r2.!54+r:022D"dC355tRF-//r5AC 	EDDDDDDD$$$$$$%%%%%%	< 	< 	< 	< 	<
 /4 	R 	R*T4c$ii(( R R N$$X/@/@t/L/LMMM  +<+<T4+P+PQQQR R R R R R R R R R R R R R R	 	 	 	 	9#A 	 	 		 	 	 	 	)G 	 	 		/ 	/ 	/ 	/ 	/ 	/ 	/ 	/	/ 	/ 	/ 	/ 	/Iy/M 	/ 	/ 	/ 	[2%%t4Yd|T2!!##T2t4''))4U;""$$dB5
 	
 /4 	E 	E*T4c$ii(( E EQRR!z$Q00!'$-- ?$$XttT{;;;$$X/B/B4t/T/TUUU$$XttU|<<<$$Xww~>>>  44+@+@+@AAA  ::dD&+I+IJJJ  44+A&+A+ABBB  77D+CF+C+CDDDE E E E E E E E E E E E E E E	E 	Es&   !AD11D5	8D5	
DL!!L%	(L%	N)r   r   r   r  r  r  rV  r   r   r
   rr  rr  F  s`        X X X&	V 	V 	V& & &JE JE JE JE JEr   rr  c                   @    e Zd Zd Zed             Zed             ZdS )Ac                     d S r   r   )r   rT   rX   s      r
   method_two_argszA.method_two_args  s    r   c                      d S r   r   r   r   r
   static_no_argszA.static_no_args      r   c                    d S r   r   args    r
   positional_onlyzA.positional_only  r  r   N)r   r   r   r  rz   r  r  r   r   r
   r  r    sY             \   \  r   r  c                   L    e Zd Zej        d             Zd Zd Zd Zd Z	d Z
dS )!TestErrorMessagesUseQualifiedNamec              #      K   |                      t                    5 }d V  d d d            n# 1 swxY w Y   |                     t          |j                  |           d S r   )assertRaisesr0   r'   r   	exception)r   messagecms      r
   check_raises_type_errorz9TestErrorMessagesUseQualifiedName.check_raises_type_error  s      y)) 	REEE	 	 	 	 	 	 	 	 	 	 	 	 	 	 	R\**G44444s   .22c                     d}|                      |          5  t                                          d           d d d            d S # 1 swxY w Y   d S )Nz?A.method_two_args() missing 1 required positional argument: 'y'rT   r  r  r  r9   s     r
   test_missing_argumentsz8TestErrorMessagesUseQualifiedName.test_missing_arguments  s    O))#.. 	% 	%CC$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%s   "AAAc                     d}|                      |          5  t                              d           d d d            d S # 1 swxY w Y   d S )Nz?A.static_no_args() takes 0 positional arguments but 1 was givenzoops it's an arg)r  r  r  r9   s     r
   test_too_many_positionalz:TestErrorMessagesUseQualifiedName.test_too_many_positional  s    O))#.. 	1 	1/000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s   A  AAc                     d}|                      |          5  t                              d           d d d            d S # 1 swxY w Y   d S )NzYA.positional_only() got some positional-only arguments passed as keyword arguments: 'arg'rT   r  )r  r  r  r9   s     r
   &test_positional_only_passed_as_keywordzHTestErrorMessagesUseQualifiedName.test_positional_only_passed_as_keyword  s    i))#.. 	' 	'#&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	's   AAAc                     d}|                      |          5  t                                          d           d d d            d S # 1 swxY w Y   d S )Nz<A.method_two_args() got an unexpected keyword argument 'bad'rT   )badr  r9   s     r
   test_unexpected_keywordz9TestErrorMessagesUseQualifiedName.test_unexpected_keyword  s    L))#.. 	) 	)CCC(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s   #AAAc                     d}|                      |          5  t                                          ddd           d d d            d S # 1 swxY w Y   d S )Nz8A.method_two_args() got multiple values for argument 'x'rT   rX   oopsrS   r  r9   s     r
   test_multiple_valuesz6TestErrorMessagesUseQualifiedName.test_multiple_values  s    H))#.. 	4 	4CCSF333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4s   %A

AAN)r   r   r   
contextlibcontextmanagerr  r  r  r  r  r  r   r   r
   r  r    s~         5 5 5
% % %
1 1 1
' ' '
) ) )
4 4 4 4 4r   r  __main__)$unittesttest.supportr   r   r   rj   r    r   r^  r  r   r   TestCaser   r4   r   r  r  r"  r%  r,  r0  r2  rh  objectrC  r=  r  r  rm  rp  rr  r  r  r   mainr   r   r
   <module>r     s    % % % % % %   III          				    & & & & &S & & &    H%   8 WC WC WC WC WC("3 WC WC WCvH
 H
 H
 H
 H
X. H
 H
 H
VA A A A A%; A A A< < < < <"8 < < <1 1 1 1 1*@ 1 1 1" " " " "#9 " " "             +--b3 b3 b3 b3 b3H% b3 b3 b3J % &   
  
tE tE tE tE tE" tE tE tEn
 
 
 
 
 
 
 
 4 4 4 4 4(9 4 4 4D zHMOOOOO s    