o
    K+g                     @   s   d Z g dZi ZdddZdd Zze W n	 ey   Y nw dd Zeeee d	d
 Zee	e
eB e dd ZdZe	e
jZdd Zdd Zdd Zdd Zi Zi Zi Zdd Zdd Zdd ZdS )zHelper to provide extensibility for pickle.

This is only useful to add pickle support for extension types defined in
C, not for instances of user-defined classes.
)pickleconstructoradd_extensionremove_extensionclear_extension_cacheNc                 C   s0   t |std|t| < |d urt| d S d S )Nz$reduction functions must be callable)callable	TypeErrordispatch_tabler   )Zob_typeZpickle_functionZconstructor_ob r	   9/var/www/html/squashfs-root/usr/lib/python3.10/copyreg.pyr      s   r   c                 C   s   t | stdd S )Nzconstructors must be callable)r   r   )objectr	   r	   r
   r      s   r   c                 C   s   t | j| jffS N)complexrealimag)cr	   r	   r
   pickle_complex"   s   r   c                 C   s"   dd l }dd l}|j|j| jffS )N    )	functoolsoperatorreduceor___args__)objr   r   r	   r	   r
   pickle_union'   s   r   c                 C   s>   |t u rt | }|S || |}|jt jkr||| |S r   )r   __new____init__)clsbasestater   r	   r	   r
   _reconstructor/   s   
r   i   c           	      C   s  |dk sJ | j }|jD ]}t|dr|jt@ s n|j}t|tr)|j|u r) nqt	}|t	u r3d }n||u r@t
d|jd|| }|||f}z| j}W n, tyz   t| dd rgt
d|jd| d z| j}W n tyw   d }Y nw Y nw | }|rt||fS t|fS )N   	__flags__zcannot pickle z object	__slots__zf object: a class that defines __slots__ without defining __getstate__ cannot be pickled with protocol )	__class____mro__hasattrr!   	_HEAPTYPEr   
isinstance	_new_type__self__r   r   __name____getstate__AttributeErrorgetattr__dict__r   )	selfprotor   r   newr   argsgetstatedictr	   r	   r
   
_reduce_ex=   sH   




r5   c                 G   s   | j | g|R  S r   r   )r   r2   r	   r	   r
   
__newobj__d   s   r7   c                 C   s   | j | g|R i |S )zUsed by pickle protocol 4, instead of __newobj__ to allow classes with
    keyword-only arguments to be pickled correctly.
    r6   )r   r2   kwargsr	   r	   r
   __newobj_ex__g   s   r9   c                 C   s   | j d}|dur|S g }t| dsnI| jD ]E}d|j v r\|j d }t|tr+|f}|D ].}|dv r4q-|drV|dsV|j	d}|rP|
d||f  q-|
| q-|
| q-qz|| _W |S    Y |S )a  Return a list of slot names for a given class.

    This needs to find slots defined by the class and its bases, so we
    can't simply return the __slots__ attribute.  We must walk down
    the Method Resolution Order and concatenate the __slots__ of each
    class found there.  (This assumes classes don't modify their
    __slots__ attribute to misrepresent their slots after the class is
    defined.)
    __slotnames__Nr"   )r.   __weakref_____z_%s%s)r.   getr%   r$   r'   str
startswithendswithr*   lstripappendr:   )r   namesr   ZslotsnameZstrippedr	   r	   r
   
_slotnamesm   s6   




rF   c                 C   s   t |}d|  krdkstd td| |f}t||kr*t||kr*dS |tv r8td|t| f |tv rFtd|t| f |t|< |t|< dS )zRegister an extension code.   izcode out of rangeNz)key %s is already registered with code %sz$code %s is already in use for key %s)int
ValueError_extension_registryr>   _inverted_registrymodulerE   codekeyr	   r	   r
   r      s&   

r   c                 C   sV   | |f}t ||kst||krtd||f t |= t|= |tv r)t|= dS dS )z0Unregister an extension code.  For testing only.z%key %s is not registered with code %sN)rJ   r>   rK   rI   _extension_cacherL   r	   r	   r
   r      s   
r   c                   C   s   t   d S r   )rP   clearr	   r	   r	   r
   r      s   r   r   )__doc____all__r   r   r   r   	NameErrorr   r   typerH   r?   r   r&   r   r(   r5   r7   r9   rF   rJ   rK   rP   r   r   r   r	   r	   r	   r
   <module>   s6    

	
'<