a °x–ajã@s°dZgd¢ZiZddd„Zdd„ZzeWney<Yn0dd„Zeeeeƒd d „Zd Z e e j ƒZ d d „Zdd„Zdd„Zdd„ZiZiZiZdd„Zdd„Zdd„ZdS)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_cacheNcCs,t|ƒstdƒ‚|t|<|dur(t|ƒdS)Nz$reduction functions must be callable)ÚcallableÚ TypeErrorÚdispatch_tabler)Úob_typeÚpickle_functionÚconstructor_ob©r ú/usr/lib/python3.9/copyreg.pyr s rcCst|ƒstdƒ‚dS)Nzconstructors must be callable)rr)Úobjectr r r rsrcCst|j|jffS©N)ÚcomplexÚrealÚimag)Úcr r r Úpickle_complex"srcCs<|turt |¡}n$| ||¡}|jtjkr8| ||¡|Sr)rÚ__new__Ú__init__)ÚclsÚbaseÚstateÚobjr r r Ú_reconstructor)s     ric Cs|dks J‚|j}|jD]:}t|dƒr4|jt@s4qX|j}t|tƒr|j|urqXqt }|t urfd}n"||ur€t d|j ›dƒ‚||ƒ}|||f}z |j }WnXt yôt|ddƒrÎt d|j ›d|›ƒd‚z |j}Wnt yîd}Yn0Yn0|ƒ}|r t||fSt|fSdS)NéÚ __flags__zcannot 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__rrÚ__name__Ú __getstate__ÚAttributeErrorÚgetattrÚ__dict__r) ÚselfÚprotorrÚnewrÚargsÚgetstateÚdictr r r Ú _reduce_ex7s@       ýý   r1cGs|j|g|¢RŽSr©r)rr.r r r Ú __newobj__^sr3cCs|j|g|¢Ri|¤ŽS)zUsed by pickle protocol 4, instead of __newobj__ to allow classes with keyword-only arguments to be pickled correctly. r2)rr.Úkwargsr r r Ú __newobj_ex__asr5cCsØ|j d¡}|dur|Sg}t|dƒs(n”|jD]Œ}d|jvr.|jd}t|tƒrV|f}|D]^}|dvrjqZqZ| d¡r®| d¡s®|j  d¡}|r¢|  d||f¡q¸|  |¡qZ|  |¡qZq.z ||_ Wn Yn0|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Úappendr6)rÚnamesrÚslotsÚnameÚstrippedr r r Ú _slotnamesgs2         rDcCsšt|ƒ}d|krdks&ntdƒ‚||f}t |¡|krNt |¡|krNdS|tvrjtd|t|fƒ‚|tvr†td|t|fƒ‚|t|<|t|<dS)zRegister an extension code.éiÿÿÿzcode 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©ÚmodulerBÚcodeÚkeyr r r r©s$ ÿ ÿ ÿrcCsR||f}t |¡|ks$t |¡|kr4td||fƒ‚t|=t|=|tvrNt|=dS)z0Unregister an extension code. For testing only.z%key %s is not registered with code %sN)rHr:rIrGÚ_extension_cacherJr r r r»s ÿÿrcCs t ¡dSr)rNÚclearr r r r rÇsr)N)Ú__doc__Ú__all__rrrrÚ NameErrorrrr"ÚtyperFrr$r1r3r5rDrHrIrNrrrr r r r Ús.     '<