a
    ze^`                     @   sN  d dl Z d dlmZ zd dlZW n ey6   dZY n0 d dlZd dlZd dlZd dlZG dd de j	Z
eG dd de j	ZG dd de j	ZG d	d
 d
eZG dd deZG dd deZG dd deZdd Zdd ZG dd dZe Ze ZG dd de j	ZdZdZdd Zdd ZG dd  d e j	Zed!krJe   dS )"    N)cpython_onlyc                   @   s   e Zd Zdd ZdS )FunctionCallsc                 C   s^   t ddg}|d t| }dd }|f i |}| |t | t| | d S )N)a   )b   r   c                  [   s   | S N )kwr	   r	   $/usr/lib/python3.9/test/test_call.pyfn   s    z+FunctionCalls.test_kwargs_order.<locals>.fn)collectionsOrderedDictmove_to_endlistitemsZassertIsInstancedictassertEqual)selfZodexpectedr   resr	   r	   r   test_kwargs_order   s    
zFunctionCalls.test_kwargs_orderN)__name__
__module____qualname__r   r	   r	   r	   r   r      s   r   c                   @   s  e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Zd;d< Z d=d> Z!d?d@ Z"dAdB Z#dCS )DCFunctionCallsErrorMessagesc                 C   s   d}|  t|i j d S )Nz7__contains__\(\) takes exactly one argument \(0 given\)assertRaisesRegex	TypeError__contains__r   msgr	   r	   r   test_varargs0    s    z)CFunctionCallsErrorMessages.test_varargs0c                 C   s   d}|  t|i jdd d S )Nz7__contains__\(\) takes exactly one argument \(2 given\)r   r   r   r    r	   r	   r   test_varargs2$   s    z)CFunctionCallsErrorMessages.test_varargs2c                 C   s   d}|  t|tjddd d S )Nz@^from_bytes\(\) takes exactly 2 positional arguments \(3 given\)   alittleF)r   r   int
from_bytesr    r	   r	   r   test_varargs3(   s    z)CFunctionCallsErrorMessages.test_varargs3c                 C   s,   d}|  t|i j d}|  t|i j d S )Nz'get expected at least 1 argument, got 0zexpected 1 argument, got 0)r   r   get__delattr__r    r	   r	   r   test_varargs1min,   s    z,CFunctionCallsErrorMessages.test_varargs1minc                 C   s   d}|  t|t d S )Nz,getattr expected at least 2 arguments, got 0r   r   getattrr    r	   r	   r   test_varargs2min3   s    z,CFunctionCallsErrorMessages.test_varargs2minc                 C   s   d}|  t|tdd d S )Nz(input expected at most 1 argument, got 2r   r   )r   r   inputr    r	   r	   r   test_varargs1max7   s    z,CFunctionCallsErrorMessages.test_varargs1maxc                 C   s   d}|  t|i jddd d S )Nz'get expected at most 2 arguments, got 3r   r      )r   r   r)   r    r	   r	   r   test_varargs2max;   s    z,CFunctionCallsErrorMessages.test_varargs2maxc                 C   s   d}| j t|i jdd d S )N+__contains__\(\) takes no keyword argumentsr   xr   r    r	   r	   r   test_varargs1_kw?   s    z,CFunctionCallsErrorMessages.test_varargs1_kwc                 C   s   d}| j t|i jddd d S )Nr3   r   r5   yr   r    r	   r	   r   test_varargs2_kwC   s    z,CFunctionCallsErrorMessages.test_varargs2_kwc                 C   s   d}| j t|tdd d S )Nz#bool\(\) takes no keyword argumentsr   r4   )r   r   boolr    r	   r	   r   test_varargs3_kwG   s    z,CFunctionCallsErrorMessages.test_varargs3_kwc                 C   s   d}| j t|g jdd d S )Nz-^list[.]index\(\) takes no keyword arguments$r   r4   )r   r   indexr    r	   r	   r   test_varargs4_kwK   s    z,CFunctionCallsErrorMessages.test_varargs4_kwc                 C   s   d}| j t|tdd d S )Nz(^hasattr\(\) takes no keyword arguments$r   r4   )r   r   hasattrr    r	   r	   r   test_varargs5_kwO   s    z,CFunctionCallsErrorMessages.test_varargs5_kwc                 C   s   d}| j t|tdd d S )Nz(^getattr\(\) takes no keyword arguments$r   r4   r,   r    r	   r	   r   test_varargs6_kwS   s    z,CFunctionCallsErrorMessages.test_varargs6_kwc                 C   s   d}| j t|tdd d S )Nz%^next\(\) takes no keyword arguments$r   r4   )r   r   nextr    r	   r	   r   test_varargs7_kwW   s    z,CFunctionCallsErrorMessages.test_varargs7_kwc                 C   s   d}| j t|tjdd d S )Nz/^_struct[.]pack\(\) takes no keyword arguments$r   r4   )r   r   structpackr    r	   r	   r   test_varargs8_kw[   s    z,CFunctionCallsErrorMessages.test_varargs8_kwc                 C   s   d}| j t|tjdd d S )Nz4^_struct[.]pack_into\(\) takes no keyword arguments$r   r4   )r   r   rC   	pack_intor    r	   r	   r   test_varargs9_kw_   s    z,CFunctionCallsErrorMessages.test_varargs9_kwc                 C   s    d}| j t|t jdd d S )Nz.^deque[.]index\(\) takes no keyword arguments$r   r4   )r   r   r   dequer<   r    r	   r	   r   test_varargs10_kwc   s    z-CFunctionCallsErrorMessages.test_varargs10_kwc                 C   s&   d}| j t|tjjtddd d S )Nz.^Struct[.]pack\(\) takes no keyword arguments$ r   r4   )r   r   rC   StructrD   r    r	   r	   r   test_varargs11_kwg   s    z-CFunctionCallsErrorMessages.test_varargs11_kwc                 C   s   d}| j t|ttd d S )Nz-^staticmethod\(\) takes no keyword arguments$func)r   r   staticmethodidr    r	   r	   r   test_varargs12_kwk   s    z-CFunctionCallsErrorMessages.test_varargs12_kwc                 C   s   d}| j t|ttd d S )Nz,^classmethod\(\) takes no keyword arguments$rM   )r   r   classmethodrP   r    r	   r	   r   test_varargs13_kwo   s    z-CFunctionCallsErrorMessages.test_varargs13_kwc                 C   s    d}| j t|tjdddd d S )Nz:^product\(\) takes at most 1 keyword argument \(2 given\)$r   r   r   )repeatfoo)r   r   	itertoolsproductr    r	   r	   r   test_varargs14_kws   s    
z-CFunctionCallsErrorMessages.test_varargs14_kwc              	   C   s    d}| j t|tddddd d S )Nz?^ImportError\(\) takes at most 2 keyword arguments \(3 given\)$r   r   r   r1   )namepathrU   )r   r   ImportErrorr    r	   r	   r   test_varargs15_kwx   s    
z-CFunctionCallsErrorMessages.test_varargs15_kwc              	   C   s    d}| j t|tddddd d S )Nz7^min\(\) takes at most 2 keyword arguments \(3 given\)$r   r   r   r1   )defaultkeyrU   )r   r   minr    r	   r	   r   test_varargs16_kw}   s    
z-CFunctionCallsErrorMessages.test_varargs16_kwc                 C   s$   d}| j t|tddddddd	 d S )	Nz9^print\(\) takes at most 4 keyword arguments \(5 given\)$r   r   r   r1         )sependfileflushrU   )r   r   printr    r	   r	   r   test_varargs17_kw   s    z-CFunctionCallsErrorMessages.test_varargs17_kwc                 C   s   d}|  t|i jd d S )Nz'keys\(\) takes no arguments \(1 given\)r   r   r   keysr    r	   r	   r   test_oldargs0_1   s    z+CFunctionCallsErrorMessages.test_oldargs0_1c                 C   s   d}|  t|i jdd d S )Nz'keys\(\) takes no arguments \(2 given\)r   r   ri   r    r	   r	   r   test_oldargs0_2   s    z+CFunctionCallsErrorMessages.test_oldargs0_2c                 C   s   d}| j t|i jdd d S )N#keys\(\) takes no keyword argumentsr   r4   ri   r    r	   r	   r   test_oldargs0_1_kw   s    z.CFunctionCallsErrorMessages.test_oldargs0_1_kwc                 C   s   d}| j t|i jddd d S )Nrm   r   r7   ri   r    r	   r	   r   test_oldargs0_2_kw   s    z.CFunctionCallsErrorMessages.test_oldargs0_2_kwc                 C   s   d}|  t|g j d S )Nz0count\(\) takes exactly one argument \(0 given\)r   r   countr    r	   r	   r   test_oldargs1_0   s    z+CFunctionCallsErrorMessages.test_oldargs1_0c                 C   s   d}|  t|g jdd d S )Nz0count\(\) takes exactly one argument \(2 given\)r   r   rp   r    r	   r	   r   test_oldargs1_2   s    z+CFunctionCallsErrorMessages.test_oldargs1_2c                 C   s   d}| j t|g jdd d S N$count\(\) takes no keyword argumentsr   r4   rp   r    r	   r	   r   test_oldargs1_0_kw   s    z.CFunctionCallsErrorMessages.test_oldargs1_0_kwc                 C   s   d}| j t|g ji dd d S rt   rp   r    r	   r	   r   test_oldargs1_1_kw   s    z.CFunctionCallsErrorMessages.test_oldargs1_1_kwc                 C   s   d}| j t|g jddd d S )Nru   r   r7   rp   r    r	   r	   r   test_oldargs1_2_kw   s    z.CFunctionCallsErrorMessages.test_oldargs1_2_kwN)$r   r   r   r"   r#   r(   r+   r.   r0   r2   r6   r9   r;   r=   r?   r@   rB   rE   rG   rI   rL   rQ   rS   rX   r\   r`   rh   rk   rl   rn   ro   rr   rs   rv   rw   rx   r	   r	   r	   r   r      sB   r   c                   @   s   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2S )3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                 C   s   t  | _| _d S r   )	_testcapiobjexpected_selfr   r	   r	   r   setUp   s    zTestCallingConventions.setUpc                 C   s"   |  | jddd| jdf d S Nr   r   r1   r   r   r1   r   r{   meth_varargsr|   r}   r	   r	   r   test_varargs   s    z#TestCallingConventions.test_varargsc                 C   s   |  | jjd | jdf d S Nr   r   r}   r	   r	   r   test_varargs_ext   s    
z'TestCallingConventions.test_varargs_extc                    s   d}  t| fdd d S )Nz+meth_varargs\(\) takes no keyword argumentsc                      s    j jddS Nr   )k)r{   r   r	   r}   r	   r   <lambda>       z>TestCallingConventions.test_varargs_error_kw.<locals>.<lambda>r   r   r    r	   r}   r   test_varargs_error_kw   s    z,TestCallingConventions.test_varargs_error_kwc                 C   s.   |  | jjddddd| jddddf d S Nr   r   r1   ra   r   r   r   r   r   r{   meth_varargs_keywordsr|   r}   r	   r	   r   test_varargs_keywords   s    z,TestCallingConventions.test_varargs_keywordsc                 C   s6   |  | jjddgi ddd| jddddf d S r   r   r}   r	   r	   r   test_varargs_keywords_ext   s    z0TestCallingConventions.test_varargs_keywords_extc                 C   s   |  | jd| jdf d S Nr   r   r{   meth_or|   r}   r	   r	   r   test_o   s    zTestCallingConventions.test_oc                 C   s    |  | jjdg | jdf d S r   r   r}   r	   r	   r   
test_o_ext   s    z!TestCallingConventions.test_o_extc                 C   s   d}|  t|| jj d S )Nz1meth_o\(\) takes exactly one argument \(0 given\))r   r   r{   r   r    r	   r	   r   test_o_error_no_arg   s    z*TestCallingConventions.test_o_error_no_argc                    s   d}  t| fdd d S )Nz1meth_o\(\) takes exactly one argument \(2 given\)c                      s    j ddS Nr   r   r{   r   r	   r}   r	   r   r      r   z>TestCallingConventions.test_o_error_two_args.<locals>.<lambda>r   r    r	   r}   r   test_o_error_two_args   s    z,TestCallingConventions.test_o_error_two_argsc                    s   d}  t| fdd d S )Nz1meth_o\(\) takes exactly one argument \(3 given\)c                      s    j jd S r   r   r	   r}   r	   r   r      r   z9TestCallingConventions.test_o_error_ext.<locals>.<lambda>r   r    r	   r}   r   test_o_error_ext   s    z'TestCallingConventions.test_o_error_extc                    s   d}  t| fdd d S )N%meth_o\(\) takes no keyword argumentsc                      s    j jddS r   r   r	   r}   r	   r   r      r   z8TestCallingConventions.test_o_error_kw.<locals>.<lambda>r   r    r	   r}   r   test_o_error_kw   s    z&TestCallingConventions.test_o_error_kwc                    s   d}  t| fdd d S )Nr   c                      s    j jddS r   r   r	   r}   r	   r   r      r   z<TestCallingConventions.test_o_error_arg_kw.<locals>.<lambda>r   r    r	   r}   r   test_o_error_arg_kw   s    z*TestCallingConventions.test_o_error_arg_kwc                 C   s   |  | j | j d S r   r   r{   meth_noargsr|   r}   r	   r	   r   test_noargs   s    z"TestCallingConventions.test_noargsc                 C   s   |  | jjg  | j d S r   r   r}   r	   r	   r   test_noargs_ext   s    z&TestCallingConventions.test_noargs_extc                    s   d}  t| fdd d S )Nz.meth_noargs\(\) takes no arguments \(1 given\)c                      s    j dS r   r{   r   r	   r}   r	   r   r     r   z>TestCallingConventions.test_noargs_error_arg.<locals>.<lambda>r   r    r	   r}   r   test_noargs_error_arg  s    z,TestCallingConventions.test_noargs_error_argc                    s   d}  t| fdd d S )Nz.meth_noargs\(\) takes no arguments \(2 given\)c                      s    j ddS r   r   r	   r}   r	   r   r   
  r   z?TestCallingConventions.test_noargs_error_arg2.<locals>.<lambda>r   r    r	   r}   r   test_noargs_error_arg2  s    z-TestCallingConventions.test_noargs_error_arg2c                    s   d}  t| fdd d S )Nz.meth_noargs\(\) takes no arguments \(3 given\)c                      s    j jd S r   r   r	   r}   r	   r   r     r   z>TestCallingConventions.test_noargs_error_ext.<locals>.<lambda>r   r    r	   r}   r   test_noargs_error_ext  s    z,TestCallingConventions.test_noargs_error_extc                    s   d}  t| fdd d S )Nz*meth_noargs\(\) takes no keyword argumentsc                      s    j jddS r   r   r	   r}   r	   r   r     r   z=TestCallingConventions.test_noargs_error_kw.<locals>.<lambda>r   r    r	   r}   r   test_noargs_error_kw  s    z+TestCallingConventions.test_noargs_error_kwc                 C   s"   |  | jddd| jdf d S r   r   r{   meth_fastcallr|   r}   r	   r	   r   test_fastcall  s    z$TestCallingConventions.test_fastcallc                 C   s   |  | jjd | jdf d S r   r   r}   r	   r	   r   test_fastcall_ext  s    
z(TestCallingConventions.test_fastcall_extc                    s   d}  t| fdd d S )Nz,meth_fastcall\(\) takes no keyword argumentsc                      s    j jddS r   )r{   r   r	   r}   r	   r   r   (  r   z?TestCallingConventions.test_fastcall_error_kw.<locals>.<lambda>r   r    r	   r}   r   test_fastcall_error_kw%  s    z-TestCallingConventions.test_fastcall_error_kwc                 C   s.   |  | jjddddd| jddddf d S r   r   r{   meth_fastcall_keywordsr|   r}   r	   r	   r   test_fastcall_keywords+  s    z-TestCallingConventions.test_fastcall_keywordsc                 C   s2   |  | jjdi ddd| jddddf d S )Nr   r1   ra   r   r   r}   r	   r	   r   test_fastcall_keywords_ext1  s    z1TestCallingConventions.test_fastcall_keywords_extN)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   ry      s2   
ry   c                   @   s   e Zd ZdZdd ZdS )TestCallingConventionsInstancez?Test calling instance methods using various calling conventionsc                 C   s   t   | _| _d S r   )rz   MethInstancer{   r|   r}   r	   r	   r   r~   ;  s    z$TestCallingConventionsInstance.setUpNr   r   r   r   r~   r	   r	   r	   r   r   8  s   r   c                   @   s   e Zd ZdZdd ZdS )TestCallingConventionsClassz<Test calling class methods using various calling conventionsc                 C   s   t j | _| _d S r   rz   	MethClassr{   r|   r}   r	   r	   r   r~   B  s    z!TestCallingConventionsClass.setUpNr   r	   r	   r	   r   r   ?  s   r   c                   @   s   e Zd ZdZdd ZdS )#TestCallingConventionsClassInstancez&Test calling class methods on instancec                 C   s   t  | _t j| _d S r   r   r}   r	   r	   r   r~   I  s    
z)TestCallingConventionsClassInstance.setUpNr   r	   r	   r	   r   r   F  s   r   c                   @   s   e Zd ZdZdd ZdS )TestCallingConventionsStaticz=Test calling static methods using various calling conventionsc                 C   s   t  | _d | _d S r   )rz   
MethStaticr{   r|   r}   r	   r	   r   r~   Q  s    
z"TestCallingConventionsStatic.setUpNr   r	   r	   r	   r   r   N  s   r   c                 C   s   | |gS r   r	   arg1arg2r	   r	   r   pyfuncV  s    r   c                   C   s   dS Nnoargr	   r	   r	   r	   r   pyfunc_noargZ  s    r   c                   @   s4   e Zd Zdd Zdd Zedd Zedd Zd	S )
PythonClassc                 C   s   ||gS r   r	   )r   r   r   r	   r	   r   method_  s    zPythonClass.methodc                 C   s   dS r   r	   r}   r	   r	   r   method_noargb  s    zPythonClass.method_noargc                 C   s   dS )NrR   r	   )clsr	   r	   r   class_methode  s    zPythonClass.class_methodc                   C   s   dS )NrO   r	   r	   r	   r	   r   static_methodi  s    zPythonClass.static_methodN)	r   r   r   r   r   rR   r   rO   r   r	   r	   r	   r   r   ^  s   
r   c                   @   s8  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 Zeefeefejejfe 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 qdd Zdd Zdd Zdd Z dd Z!dS )FastCallTestsz0Test calling using various callables from C
    r   r   r   r	   r   rR   rO   )r   r   r   N){   r   r5   r8   c                 C   sP   t |tr@|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   r	   r	   r   check_result  s    zFastCallTests.check_resultc              	   C   sx   | j D ]l\}}}| j||dD t||}| || |sTt|d }| || W d    q1 sh0    Y  qd S )NrN   args)CALLS_POSARGSsubTestrz   Zpyobject_fastcallr   )r   rN   r   r   r   r	   r	   r   r     s    zFastCallTests.test_fastcallc              	   C   s   | j D ]p\}}}| j||dH t||d }| || |sXt|d d }| || W d    q1 sl0    Y  q| jD ]V\}}}}| j|||d* t|||}| || W d    q~1 s0    Y  q~d S )Nr   rN   r   kwargs)r   r   rz   Zpyobject_fastcalldictr   CALLS_KWARGS)r   rN   r   r   r   r   r	   r	   r   test_vectorcall_dict  s    ,z"FastCallTests.test_vectorcall_dictc              	   C   s,  | j D ]\}}}| j||d| t||d }| || t||d}| || |st|d d }| || t|d d}| || W d    q1 s0    Y  q| jD ]t\}}}}| j|||dF t| }|t|  }t|||}| || W d    q1 s0    Y  qd S )Nr   r	   r   )	r   r   rz   pyobject_vectorcallr   r   r   rj   values)r   rN   r   r   r   r   kwnamesr	   r	   r   test_vectorcall  s"    ,zFastCallTests.test_vectorcallc                 C   s6   G dd d}|| d}t ddd|fi |j d S )Nc                   @   s"   e Zd ZdgZdd Zdd ZdS )z>FastCallTests.test_fastcall_clearing_dict.<locals>.IntWithDictr   c                 [   s
   || _ d S r   )r   )r   r   r	   r	   r   __init__
  s    zGFastCallTests.test_fastcall_clearing_dict.<locals>.IntWithDict.__init__c                 S   s   | j   t  dS )Nr   )r   cleargcZcollectr}   r	   r	   r   	__index__  s    
zHFastCallTests.test_fastcall_clearing_dict.<locals>.IntWithDict.__index__N)r   r   r   	__slots__r   r   r	   r	   r	   r   IntWithDict  s   r   )dont_inheritpassrJ   exec)compiler   )r   r   r5   r	   r	   r   test_fastcall_clearing_dict  s    z)FastCallTests.test_fastcall_clearing_dict)"r   r   r   r   r   r   r   r   r   PYTHON_INSTANCEr   r   r   r   rz   r   Z	_instancer   r   r{   r|   extendr   r   r   r   r   r   r   r   r   r   r   r   r	   r	   r	   r   r   r  s~   









r   i   i   c                 C   s   | S zsome docr	   r}   r	   r	   r   testfunction  s    r   c                C   s   | S r   r	   )r   r
   r	   r	   r   testfunction_kw   s    r   c                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )

TestPEP590c                 C   s   dd l }|dt}| ttjt@  | tt	j
jt@  | tt	jjt@  | ttjt@  | t|jt@  | tjjt@  | tjjt@  | tjjt@  G dd dtj}| |jt@  d S )Nr   r   c                   @   s   e Zd ZdS )zDTestPEP590.test_method_descriptor_flag.<locals>.MethodDescriptorHeapNr   r   r   r	   r	   r	   r   MethodDescriptorHeap6  s   r   )	functools	lru_cacher   assertFalsetyperepr	__flags__Py_TPFLAGS_METHOD_DESCRIPTOR
assertTruer   append__add__rz   MethodDescriptorBaseMethodDescriptorDerivedMethodDescriptorNopGet)r   r   cachedr   r	   r	   r   test_method_descriptor_flag'  s    z&TestPEP590.test_method_descriptor_flagc                 C   sn   |  tjjt@  |  tjjt@  | tjjt@  |  tjjt@  G dd dtj}| |jt@  d S )Nc                   @   s   e Zd ZdS )z=TestPEP590.test_vectorcall_flag.<locals>.MethodDescriptorHeapNr   r	   r	   r	   r   r   A  s   r   )	r   rz   r   r   Py_TPFLAGS_HAVE_VECTORCALLr   r   r   MethodDescriptor2)r   r   r	   r	   r   test_vectorcall_flag:  s    zTestPEP590.test_vectorcall_flagc                 C   s(   t td}t }| || | d S )Nrb   )r   rangerz   r   ZassertIs)r   r   fr	   r	   r   test_vectorcall_overrideE  s    z#TestPEP590.test_vectorcall_overridec                    s  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 di d	ft	 di d	ft
 di d
fg	}ddlm m} ddlm} ddlm}  fdd}|D ]f\}}}}	| t|: |s| |	||| | |	|||| W d    q1 s0    Y  qG dd dtj}
G dd dtj}G dd d}G d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7 }|D ] \}}}}	| t| |dd  }|||d }||}|sH| |	||  | |	 ||d  | |	||  | |	||  | |	||i | | |	|||| | |	||i | | |	||i | W d    n1 s0    Y  qd S )N*   r   )r   $   start   )r  r
   TF)r   pyvectorcall_call)
MethodType)partialc                    s&   g ||  R }t|} | ||S r   )r   r   )rN   r   r   r   r   r	   r   
vectorcallg  s    z.TestPEP590.test_vectorcall.<locals>.vectorcallc                   @   s   e Zd ZdS )z8TestPEP590.test_vectorcall.<locals>.MethodDescriptorHeapNr   r	   r	   r	   r   r   u  s   r   c                   @   s   e Zd Zdd ZdS )z>TestPEP590.test_vectorcall.<locals>.MethodDescriptorOverriddenc                 S   s   dS )Nnewr	   )r   nr	   r	   r   __call__y  s    zGTestPEP590.test_vectorcall.<locals>.MethodDescriptorOverridden.__call__N)r   r   r   r  r	   r	   r	   r   MethodDescriptorOverriddenx  s   r  c                       s   e Zd Z fddZ  ZS )z-TestPEP590.test_vectorcall.<locals>.SuperBasec                    s   t  j| S r   superr  r   r   	__class__r	   r   r  }  s    z6TestPEP590.test_vectorcall.<locals>.SuperBase.__call__r   r   r   r  __classcell__r	   r	   r  r   	SuperBase|  s   r  c                       s   e Zd Z fddZ  ZS )z9TestPEP590.test_vectorcall.<locals>.MethodDescriptorSuperc                    s   t  j| S r   r  r  r  r	   r   r    s    zBTestPEP590.test_vectorcall.<locals>.MethodDescriptorSuper.__call__r  r	   r	   r  r   MethodDescriptorSuper  s   r  r^   r  r   )lenr  r   r   sumr   r   rz   r   r   r   r   r	  typesr
  r   r  r   strr   r   update)r   Zcallsr	  r
  r  r  rN   r   r   r   r   r  r  r  Zargs1methwrappedr	   r  r   r   O  sX    


6zTestPEP590.test_vectorcallN)r   r   r   r   r  r  r   r	   r	   r	   r   r   %  s   
r   __main__)ZunittestZtest.supportr   rz   r[   rC   r   rV   r   ZTestCaser   r   ry   r   r   r   r   r   r   r   r   objectr   r   r   r   r   r   r   r   mainr	   r	   r	   r   <module>   sB   
   &w
