a
    ӗa9&                     @   s  d Z ddlZdd ZeeZedd ZeejZeejZ	eej
Zdd Zee Zd	d
 Zee Zdd Ze ZeeZe  dd Ze ZeeZG dd dZee jZeeZeg jZeejZee jZ ee!j"Z#ee$jd Z%eeZ&ze'W n8 e'y@   e( d Z)ee)Z*ee)j+Z,dZ)[)Y n0 eejZ-eej.Z/[[[[[[d$ddZ0dd Z1d%ddZ2dd Z3G dd dZ4G dd dZ5d d! Z6ee7e8 Z9d"d# e: D Z;dS )&zO
Define names for built-in types that aren't directly accessible as a builtin.
    Nc                   C   s   d S N r   r   r   (/home/manager/Python-3.9.10/Lib/types.py_f       r   c                   C   s   d S r   r   r   r   r   r   <lambda>   r   r   c                     s   d  fdd} | j d S )N   c                      s   d S r   r   r   ar   r   f   s    z_cell_factory.<locals>.fr   )__closure__)r   r   r	   r   _cell_factory   s    r   c                   c   s
   dV  d S )Nr   r   r   r   r   r   _g   s    r   c                      s   d S r   r   r   r   r   r   _c   r   r   c                   C  s
   d V  d S r   r   r   r   r   r   _ag"   s    r   c                   @   s   e Zd Zdd ZdS )_Cc                 C   s   d S r   r   selfr   r   r   _m(   r   z_C._mN)__name__
__module____qualname__r   r   r   r   r   r   '   s   r   fromkeys   r   c                 C   sN   t |}t| ||\}}}|dur*|| ||ur:||d< || ||fi |S )zBCreate a class object dynamically using the appropriate metaclass.NZ__orig_bases__)resolve_basesprepare_class)namebaseskwdsZ	exec_bodyZresolved_basesmetansr   r   r   	new_classE   s    r!   c                 C   s   t | }d}d}t| D ]t\}}t|tr6t|ts6qt|dsBq|| }d}t|tsdtdq|||| || d < |t	|d 7 }q|s| S t|S )z8Resolve MRO entries dynamically as specified by PEP 560.Fr   __mro_entries__Tz#__mro_entries__ must return a tupler   )
list	enumerate
isinstancetypeGenericAliashasattrr"   tuple	TypeErrorlen)r   Z	new_basesZupdatedZshiftibaseZnew_baser   r   r   r   O   s"    



r   c                 C   s   |du ri }nt |}d|v r*|d}n|r<t|d }nt}t|trTt||}t|drt|j| |fi |}ni }|||fS )az  Call the __prepare__ method of the appropriate metaclass.

    Returns (metaclass, namespace, kwds) as a 3-tuple

    *metaclass* is the appropriate metaclass
    *namespace* is the prepared class namespace
    *kwds* is an updated copy of the passed in kwds argument with any
    'metaclass' entry removed. If no kwds argument is passed in, this will
    be an empty dict.
    N	metaclassr   __prepare__)dictpopr&   r%   _calculate_metar(   r/   )r   r   r   r   r    r   r   r   r   d   s    


r   c                 C   s>   | }|D ]0}t |}t||r qt||r0|}qtdq|S )z%Calculate the most derived metaclass.zxmetaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases)r&   
issubclassr*   )r   r   Zwinnerr-   Z	base_metar   r   r   r2      s    


r2   c                   @   sL   e Zd ZdZdddZdddZdd Zd	d
 Zdd Zdd Z	dd Z
dS )DynamicClassAttributea  Route attribute access on a class to __getattr__.

    This is a descriptor, used to define attributes that act differently when
    accessed through an instance and through a class.  Instance access remains
    normal, but access to an attribute through a class will be routed to the
    class's __getattr__ method; this is done by raising AttributeError.

    This allows one to have properties active on an instance, and have virtual
    attributes on the class with the same name (see Enum for an example).

    Nc                 C   s>   || _ || _|| _|p|j| _|d u | _tt|dd| _d S )N__isabstractmethod__F)fgetfsetfdel__doc__overwrite_docboolgetattrr5   )r   r6   r7   r8   Zdocr   r   r   __init__   s    
zDynamicClassAttribute.__init__c                 C   s6   |d u r| j r| S t n| jd u r,td| |S )Nzunreadable attribute)r5   AttributeErrorr6   )r   instanceZ
ownerclassr   r   r   __get__   s    
zDynamicClassAttribute.__get__c                 C   s"   | j d u rtd|  || d S )Nzcan't set attribute)r7   r>   )r   r?   valuer   r   r   __set__   s    
zDynamicClassAttribute.__set__c                 C   s    | j d u rtd|  | d S )Nzcan't delete attribute)r8   r>   )r   r?   r   r   r   
__delete__   s    
z DynamicClassAttribute.__delete__c                 C   s8   | j r|jnd }t| || j| j|p(| j}| j |_ |S r   )r:   r9   r&   r7   r8   )r   r6   Zfdocresultr   r   r   getter   s    zDynamicClassAttribute.getterc                 C   s$   t | | j|| j| j}| j|_|S r   )r&   r6   r8   r9   r:   )r   r7   rD   r   r   r   setter   s    zDynamicClassAttribute.setterc                 C   s$   t | | j| j|| j}| j|_|S r   )r&   r6   r7   r9   r:   )r   r8   rD   r   r   r   deleter   s    zDynamicClassAttribute.deleter)NNNN)N)r   r   r   r9   r=   r@   rB   rC   rE   rF   rG   r   r   r   r   r4      s   


	r4   c                   @   s   e Zd Zdd Zdd Zdd Zdd Zed	d
 Zedd Z	edd Z
edd ZeZe	Ze
ZeZdd Zdd ZeZdS )_GeneratorWrapperc                 C   s2   || _ |jtu | _t|dd | _t|dd | _d S )Nr   r   )_GeneratorWrapper__wrapped	__class__GeneratorType_GeneratorWrapper__isgenr<   r   r   )r   Zgenr   r   r   r=      s    z_GeneratorWrapper.__init__c                 C   s   | j |S r   )rI   send)r   Zvalr   r   r   rM      s    z_GeneratorWrapper.sendc                 G   s   | j j|g|R  S r   )rI   throw)r   Ztprestr   r   r   rN      s    z_GeneratorWrapper.throwc                 C   s
   | j  S r   )rI   closer   r   r   r   rP      s    z_GeneratorWrapper.closec                 C   s   | j jS r   )rI   gi_coder   r   r   r   rQ      s    z_GeneratorWrapper.gi_codec                 C   s   | j jS r   )rI   gi_framer   r   r   r   rR      s    z_GeneratorWrapper.gi_framec                 C   s   | j jS r   )rI   
gi_runningr   r   r   r   rS      s    z_GeneratorWrapper.gi_runningc                 C   s   | j jS r   )rI   gi_yieldfromr   r   r   r   rT      s    z_GeneratorWrapper.gi_yieldfromc                 C   s
   t | jS r   )nextrI   r   r   r   r   __next__   s    z_GeneratorWrapper.__next__c                 C   s   | j r| jS | S r   )rL   rI   r   r   r   r   __iter__   s    z_GeneratorWrapper.__iter__N)r   r   r   r=   rM   rN   rP   propertyrQ   rR   rS   rT   cr_codecr_frame
cr_runningcr_awaitrV   rW   	__await__r   r   r   r   rH      s&   



rH   c                    s   t stdjtu rftddjtu rfjj}|d@ r@S |d@ rfj}|j|jdB d_S ddl	}ddl
 | fd	d
}|S )z2Convert regular generator function to a coroutine.z$types.coroutine() expects a callable__code__Ni         )co_flagsr   c                     sV   | i |}|j tu s.|j tu r2|jjd@ r2|S t| jrRt| jsRt|S |S )Nr`   )	rJ   CoroutineTyperK   rQ   ra   r%   Z	GeneratorZ	CoroutinerH   )argskwargsZcoro_collections_abcfuncr   r   wrapped  s    


zcoroutine.<locals>.wrapped)callabler*   rJ   FunctionTyper<   CodeTyper^   ra   replace	functoolsrf   Zwraps)rg   ra   Zcorm   rh   r   re   r   	coroutine   s"    
rn   c                 C   s    g | ]}|d d dkr|qS )Nr   _r   ).0nr   r   r   
<listcomp>+  r   rr   )r   NN)r   N)<r9   sysr   r&   rj   Z
LambdaTyper^   rk   __dict__ZMappingProxyTypeimplementationZSimpleNamespacer   ZCellTyper   rK   r   rb   rP   r   ZAsyncGeneratorTyper   r   Z
MethodTyper+   ZBuiltinFunctionTypeappendZBuiltinMethodTypeobjectr=   ZWrapperDescriptorType__str__ZMethodWrapperTypestrjoinZMethodDescriptorTyper0   ZClassMethodDescriptorType
ModuleTyper*   exc_infotbZTracebackTypetb_frameZ	FrameTypeZGetSetDescriptorType__globals__ZMemberDescriptorTyper!   r   r   r2   r4   rH   rn   r#   intr'   globals__all__r   r   r   r   <module>   s\   













 :%4