Plan 9 from Bell Labs’s /usr/web/sources/contrib/bichued/root/sys/lib/python/copy_reg.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�
��c@s�dZddklZdddddgZhZdd�Zd	�Zye	Wne
j
onXd
�Zee	ee	�d�ZdZ
d�Zd�Zd�ZhZhZhZd�Zd�Zd�ZdS(s�Helper to provide extensibility for pickle/cPickle.

This is only useful to add pickle support for extension types defined in
C, not for instances of user-defined classes.
i�(t	ClassTypetpickletconstructort
add_extensiontremove_extensiontclear_extension_cachecCsit|�tjotd��nt|�ptd��n|t|<|dj	ot|�ndS(Ns-copy_reg is not intended for use with classess$reduction functions must be callable(ttypet
_ClassTypet	TypeErrortcallabletdispatch_tabletNoneR(tob_typetpickle_functiontconstructor_ob((s/sys/lib/python/copy_reg.pyRs


cCs!t|�ptd��ndS(Nsconstructors must be callable(R	R(tobject((s/sys/lib/python/copy_reg.pyRs
cCst|i|iffS(N(tcomplextrealtimag(tc((s/sys/lib/python/copy_reg.pytpickle_complex'scCsF|tjoti|�}n#|i||�}|i||�|S(N(Rt__new__t__init__(tclstbasetstatetobj((s/sys/lib/python/copy_reg.pyt_reconstructor.s

ii	cCsL|djpt�x>|iiD]*}t|d�o|it@oPq!q!Wt}|tjo
d}n1||ijotd|i	�n||�}|i||f}y
|i
}Wn_tj
oSt|dd�otd��ny
|i
}Wq&tj
o
d}q&XnX|�}|ot||fSnt|fSdS(Nit	__flags__scan't pickle %s objectst	__slots__sNa class that defines __slots__ without defining __getstate__ cannot be pickled(tAssertionErrort	__class__t__mro__thasattrRt	_HEAPTYPERRRt__name__t__getstate__tAttributeErrortgetattrt__dict__R(tselftprotoRRtargstgetstatetdict((s/sys/lib/python/copy_reg.pyt
_reduce_ex:s2
	



	cGs|i||�S(N(R(RR*((s/sys/lib/python/copy_reg.pyt
__newobj__[scCs|iid�}|dj	o|Sng}t|d�pn�x�|iD]�}d|ijo�|id}t|t�o
|f}nxr|D]f}|djoq�q�|id�o/|id�o|i	d|i
|f�q�|i	|�q�WqKqKWy
||_WnnX|S(	s�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.)
    t
__slotnames__RR't__weakref__t__s_%s%sN(s__dict__s__weakref__(R'tgetRR!R t
isinstancet
basestringt
startswithtendswithtappendR#R/(RtnamesRtslotstname((s/sys/lib/python/copy_reg.pyt
_slotnames^s0




!
cCs�t|�}d|jo
djnp
td�n||f}ti|�|joti|�|jodSn|tjotd|t|f��n|tjotd|t|f��n|t|<|t|<dS(sRegister an extension code.ii�scode out of rangeNs)key %s is already registered with code %ss$code %s is already in use for key %s(tintt
ValueErrort_extension_registryR2t_inverted_registry(tmoduleR:tcodetkey((s/sys/lib/python/copy_reg.pyR�s



cCs|||f}ti|�|jpti|�|jotd||f��nt|=t|=|tjot|=ndS(s0Unregister an extension code.  For testing only.s%key %s is not registered with code %sN(R>R2R?R=t_extension_cache(R@R:RARB((s/sys/lib/python/copy_reg.pyR�s
cCsti�dS(N(RCtclear(((s/sys/lib/python/copy_reg.pyR�sNi(t__doc__ttypesRRt__all__R
RRRRt	NameErrorRRR"R-R.R;R>R?RCRRR(((s/sys/lib/python/copy_reg.pys<module>s.
				!		8		

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].