o
    >c                     @   s   	 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 ))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	   [/Volumes/Data/workspace/med-macos-weekly/build/ExtProjs/pyncpp/python/source/Lib/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  | j }|jD ]}t|dr|jt@ s n|j}t|tr#|j|u r# nqt	}|t	u r-d }n||u r:t
d|jd|| }|||f}z| j}W n, tyt   t| dd rat
d|jd| d z| j}W n tyq   d }Y nw Y nw | }|rt||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=   sF   




r4   c                 G   s   | j | g|R  S r   r   )r   r1   r	   r	   r
   
__newobj__d   s   r6   c                 C   s   	 | j | g|R i |S r   r5   )r   r1   kwargsr	   r	   r
   __newobj_ex__g   s   r8   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 r5q.|drW|dsW|j	d}|rQ|
d||f  q.|
| q.|
| q.qz|| _W |S    Y |S )N__slotnames__r!   )r-   __weakref_____z_%s%s)r-   getr$   r#   r&   str
startswithendswithr)   lstripappendr9   )r   namesr   ZslotsnameZstrippedr	   r	   r
   
_slotnamesm   s8   




rE   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 r9td|t| f |tv rGtd|t| f |t|< |t|< d S )N   izcode out of rangez)key %s is already registered with code %sz$code %s is already in use for key %s)int
ValueError_extension_registryr=   _inverted_registrymodulerD   codekeyr	   r	   r
   r      s(   

r   c                 C   sX   	 | |f}t ||kst||krtd||f t |= t|= |tv r*t|= d S d S )Nz%key %s is not registered with code %s)rI   r=   rJ   rH   _extension_cacherK   r	   r	   r
   r      s   
r   c                   C   s   t   d S r   )rO   clearr	   r	   r	   r
   r      s   r   r   )__all__r   r   r   r   	NameErrorr   r   typerG   r>   r   r%   r   r'   r4   r6   r8   rE   rI   rJ   rO   r   r   r   r	   r	   r	   r
   <module>   s6    

	
'<