U
    wy]                     @   s   d Z dddddgZi ZdddZdd Zze W n ek
rD   Y nX d	d
 Zeeee dd Zd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   s,   t |std|t| < |d k	r(t| d S )Nz$reduction functions must be callable)callable	TypeErrordispatch_tabler   )Zob_typeZpickle_functionZconstructor_ob r	   D/home/stadmin/Documents/SimTableSoftware/Python-3.8.0/Lib/copyreg.pyr      s
    c                 C   s   t | stdd S )Nzconstructors must be callable)r   r   )objectr	   r	   r
   r      s    c                 C   s   t | j| jffS N)complexrealimag)cr	   r	   r
   pickle_complex"   s    r   c                 C   s<   |t krt | }n$|| |}|jt jkr8||| |S r   )r   __new____init__)clsbasestateobjr	   r	   r
   _reconstructor)   s    r   i   c                 C   s   | j }|jD ]}t|dr|jt@ s q.qt}|tkr<d }n"||krVtd|jd|| }|||f}z
| j}W n\ t	k
r   t
| dd rtd|jd| d z
| j}W n t	k
r   d }Y nX Y nX | }|rt||fS t|fS d 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   r   __name____getstate__AttributeErrorgetattr__dict__r   )selfprotor   r   r   argsgetstatedictr	   r	   r
   
_reduce_ex6   s4    




r)   c                 G   s   | j | f| S r   r   )r   r&   r	   r	   r
   
__newobj__Z   s    r+   c                 C   s   | j | f||S )zUsed by pickle protocol 4, instead of __newobj__ to allow classes with
    keyword-only arguments to be pickled correctly.
    r*   )r   r&   kwargsr	   r	   r
   __newobj_ex__]   s    r-   c                 C   s   | j d}|dk	r|S g }t| ds(n| jD ]}d|j kr.|j d }t|trV|f}|D ]^}|dkrjqZqZ|dr|ds|j	d}|r|
d||f  q|
| qZ|
| qZq.z
|| _W n   Y nX |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   
isinstancestr
startswithendswithr   lstripappendr.   )r   namesr   ZslotsnameZstrippedr	   r	   r
   
_slotnamesc   s2    





r;   c                 C   s   t |}d|  krdks&n td| |f}t||krNt||krNdS |tkrjtd|t| f |tkrt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_registryr2   _inverted_registrymoduler:   codekeyr	   r	   r
   r      s$    

c                 C   sR   | |f}t ||ks$t||kr4td||f t |= t|= |tkrNt|= dS )z0Unregister an extension code.  For testing only.z%key %s is not registered with code %sN)r?   r2   r@   r>   _extension_cacherA   r	   r	   r
   r      s    c                   C   s   t   d S r   )rE   clearr	   r	   r	   r
   r      s    )N)__doc____all__r   r   r   r   	NameErrorr   r   r   r)   r+   r-   r;   r?   r@   rE   r   r   r   r	   r	   r	   r
   <module>   s4     

	$<