3
4^š^_  ã               @   s®   d Z dddddgZi Zddd„Zdd„ Zy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 )z¤Helper 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	   ún/home/aldo/Documentos/tesis/tesis/device auto/pruebas pulsar/pruebaclonado/envClonado/lib/python3.6/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 j| ƒ}n$|j| |ƒ}|jt jkr8|j||ƒ |S )N)r   Ú__new__Ú__init__)ÚclsÚbaseÚstateÚobjr	   r	   r
   Ú_reconstructor)   s    r   é   é	   c             C   sì   |dk st ‚x,| jjD ]}t|dƒr|jt@  rP qW t}|tkrHd }n || jkr`td|j ƒ‚|| ƒ}| j||f}y
| j	}W nL t
k
rÊ   t| dd ƒr¢tdƒ‚y
| j}W n t
k
rÄ   d }Y nX Y nX |ƒ }|ràt||fS t|fS d S )Né   Ú	__flags__zcan't pickle %s objectsÚ	__slots__zNa class that defines __slots__ without defining __getstate__ cannot be pickled)ÚAssertionErrorÚ	__class__Ú__mro__Úhasattrr   Ú	_HEAPTYPEr   r   Ú__name__Ú__getstate__ÚAttributeErrorÚgetattrÚ__dict__r   )ÚselfÚprotor   r   ÚargsÚgetstateÚdictr	   r	   r
   Ú
_reduce_ex6   s0    



r,   c             G   s   | j | f|žŽ S )N)r   )r   r)   r	   r	   r
   Ú
__newobj__W   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__Z   s    r/   c          	   C   sâ   | j jdƒ}|dk	r|S g }t| dƒs(nžxœ| jD ]’}d|j kr0|j d }t|tƒrX|f}xh|D ]`}|d	krnq^q^|jdƒr´|jdƒ r´|jj	dƒ}|r¨|j
d||f ƒ q¾|j
|ƒ q^|j
|ƒ q^W q0W y
|| _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&   r1   )r&   Úgetr    r   Ú
isinstanceÚstrÚ
startswithÚendswithr"   ÚlstripÚappendr0   )r   Únamesr   ZslotsÚnameÚstrippedr	   r	   r
   Ú
_slotnames`   s2    





r>   c             C   sœ   t |ƒ}d|  kodkn  s(tdƒ‚| |f}tj|ƒ|krPtj|ƒ|krPdS |tkrltd|t| f ƒ‚|tkrˆtd|t| f ƒ‚|t|< |t|< dS )zRegister an extension code.r   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_registryr4   Ú_inverted_registry)Úmoduler<   ÚcodeÚkeyr	   r	   r
   r   ¢   s    c             C   sR   | |f}t j|ƒ|ks$tj|ƒ|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)rA   r4   rB   r@   Ú_extension_cache)rC   r<   rD   rE   r	   r	   r
   r   ´   s    c               C   s   t jƒ  d S )N)rF   Úclearr	   r	   r	   r
   r   À   s    )Ni   )Ú__doc__Ú__all__r   r   r   r   Ú	NameErrorr   r   r!   r,   r-   r/   r>   rA   rB   rF   r   r   r   r	   r	   r	   r
   Ú<module>   s.   


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