o
    éT•j…'  ã                   @   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'‚ e'y�   e (¡ d Z)ee)ƒZ*ee)j+ƒZ,dZ)[)Y nw 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 ƒZ9ee8e!B ƒZ:ee;ƒZ<edƒZ=ee>ƒZ?d"d#„ e@ƒ D ƒZAdS )&zO
Define names for built-in types that aren't directly accessible as a builtin.
é    Nc                   C   ó   d S ©N© r   r   r   ú/usr/lib/python3.10/types.pyÚ_f   ó    r   c                   C   r   r   r   r   r   r   r   Ú<lambda>   r   r   c                     s   d‰ ‡ fdd„} | j d S )Né   c                      r   r   r   r   ©Úar   r   Úf   r   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   ó   €
r   c                   Ã   s   �d S r   r   r   r   r   r   Ú_c   s   € r   c                   C  s   �d V  d S r   r   r   r   r   r   Ú_ag"   r   r   c                   @   s   e Zd Zdd„ ZdS )Ú_Cc                 C   r   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.NÚ__orig_bases__)Úresolve_basesÚprepare_class)ÚnameÚbasesÚkwdsÚ	exec_bodyÚresolved_basesÚmetaÚnsr   r   r   Ú	new_classE   s   r&   c                 C   sœ   t | ƒ}d}d}t| ƒD ]9\}}t|tƒrt|tƒsqt|dƒs!q| | ¡}d}t|tƒs1tdƒ‚|||| || d …< |t	|ƒd 7 }q|sJ| 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    Ú	new_basesÚupdatedÚshiftÚiÚbaseÚ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ƒr*t||ƒ}t|dƒr:|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-   r8   )r   r    r!   r$   r%   r   r   r   r   d   s   



r   c                 C   s<   | }|D ]}t |ƒ}t||ƒrqt||ƒr|}qtdƒ‚|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    Úwinnerr5   Ú	base_metar   r   r   r;   „   s   

r;   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.  (Enum used this between Python
    versions 3.4 - 3.9 .)

    Subclass from this to use a different method of accessing virtual atributes
    and still be treated properly by the inspect module. (Enum uses this since
    Python 3.10 .)

    Nc                 C   s>   || _ || _|| _|p|j| _|d u | _tt|ddƒƒ| _d S )NÚ__isabstractmethod__F)ÚfgetÚfsetÚfdelÚ__doc__Úoverwrite_docÚboolÚgetattrr@   )r   rA   rB   rC   Údocr   r   r   Ú__init__¦   s   
zDynamicClassAttribute.__init__c                 C   s4   |d u r| j r	| S tƒ ‚| jd u rtdƒ‚|  |¡S )Nzunreadable attribute)r@   ÚAttributeErrorrA   )r   ÚinstanceÚ
ownerclassr   r   r   Ú__get__°   s   

zDynamicClassAttribute.__get__c                 C   s"   | j d u r	tdƒ‚|   ||¡ d S )Nzcan't set attribute)rB   rJ   )r   rK   Úvaluer   r   r   Ú__set__¹   s   
zDynamicClassAttribute.__set__c                 C   s    | j d u r	tdƒ‚|   |¡ d S )Nzcan't delete attribute)rC   rJ   )r   rK   r   r   r   Ú
__delete__¾   s   
z DynamicClassAttribute.__delete__c                 C   s8   | j r|jnd }t| ƒ|| j| j|p| jƒ}| j |_ |S r   )rE   rD   r+   rB   rC   )r   rA   ÚfdocÚresultr   r   r   ÚgetterÃ   s   zDynamicClassAttribute.getterc                 C   s$   t | ƒ| j|| j| jƒ}| j|_|S r   )r+   rA   rC   rD   rE   )r   rB   rR   r   r   r   ÚsetterÉ   ó   zDynamicClassAttribute.setterc                 C   s$   t | ƒ| j| j|| jƒ}| j|_|S r   )r+   rA   rB   rD   rE   )r   rC   rR   r   r   r   ÚdeleterÎ   rU   zDynamicClassAttribute.deleter)NNNNr   )r   r   r   rD   rI   rM   rO   rP   rS   rT   rV   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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__isgenrG   r   r   )r   Úgenr   r   r   rI   Ö   s   z_GeneratorWrapper.__init__c                 C   s   | j  |¡S r   )rX   Úsend)r   Úvalr   r   r   r]   Û   s   z_GeneratorWrapper.sendc                 G   s   | j j|g|¢R Ž S r   )rX   Úthrow)r   ÚtpÚrestr   r   r   r_   Ý   s   z_GeneratorWrapper.throwc                 C   s
   | j  ¡ S r   )rX   Úcloser   r   r   r   rb   ß   ó   
z_GeneratorWrapper.closec                 C   ó   | j jS r   )rX   Úgi_coder   r   r   r   re   á   ó   z_GeneratorWrapper.gi_codec                 C   rd   r   )rX   Úgi_framer   r   r   r   rg   ä   rf   z_GeneratorWrapper.gi_framec                 C   rd   r   )rX   Ú
gi_runningr   r   r   r   rh   ç   rf   z_GeneratorWrapper.gi_runningc                 C   rd   r   )rX   Úgi_yieldfromr   r   r   r   ri   ê   rf   z_GeneratorWrapper.gi_yieldfromc                 C   s
   t | jƒS r   )ÚnextrX   r   r   r   r   Ú__next__ñ   rc   z_GeneratorWrapper.__next__c                 C   s   | j r| jS | S r   )r[   rX   r   r   r   r   Ú__iter__ó   s   z_GeneratorWrapper.__iter__N)r   r   r   rI   r]   r_   rb   Úpropertyre   rg   rh   ri   Úcr_codeÚcr_frameÚ
cr_runningÚcr_awaitrk   rl   Ú	__await__r   r   r   r   rW   Ô   s(    



rW   c                    s’   t ˆƒstdƒ‚ˆjtu r3tˆddƒjtu r3ˆjj}|d@ r ˆS |d@ r3ˆ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 r|jjd@ r|S t|ˆ jƒr)t|ˆ jƒs)t|ƒS |S )Nru   )	rY   ÚCoroutineTyperZ   re   rv   r*   Ú	GeneratorÚ	CoroutinerW   )ÚargsÚkwargsÚcoro©Ú_collections_abcÚfuncr   r   Úwrapped  s   

ÿzcoroutine.<locals>.wrapped)Úcallabler/   rY   ÚFunctionTyperG   ÚCodeTypers   rv   ÚreplaceÚ	functoolsr~   Úwraps)r   rv   Úcor…   r€   r   r}   r   Ú	coroutineù   s    
rˆ   c                 C   s    g | ]}|d d… dkr|‘qS )Nr	   Ú_r   )Ú.0Únr   r   r   Ú
<listcomp>3  s     rŒ   )r   NN)r   N)BrD   Úsysr   r+   r‚   Ú
LambdaTypers   rƒ   Ú__dict__ÚMappingProxyTypeÚimplementationÚSimpleNamespacer   ÚCellTyper   rZ   r   rw   rb   r   ÚAsyncGeneratorTyper   r   Ú
MethodTyper0   ÚBuiltinFunctionTypeÚappendÚBuiltinMethodTypeÚobjectrI   ÚWrapperDescriptorTypeÚ__str__ÚMethodWrapperTypeÚstrÚjoinÚMethodDescriptorTyper9   ÚClassMethodDescriptorTypeÚ
ModuleTyper/   Úexc_infoÚtbÚTracebackTypeÚtb_frameÚ	FrameTypeÚGetSetDescriptorTypeÚ__globals__ÚMemberDescriptorTyper&   r   r   r;   r?   rW   rˆ   r(   Úintr,   Ú	UnionTypeÚEllipsisÚEllipsisTypeÚNoneTypeÚNotImplementedÚNotImplementedTypeÚglobalsÚ__all__r   r   r   r   Ú<module>   sh    









ü




 ?%3