a DOgj@sdZgdZiZdddZddZzeWney<Yn0ddZeeeed d Zd Z e e j Z d d ZddZddZddZiZiZiZddZddZddZdS)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_extensionremove_extensionclear_extension_cacheNcCs,t|std|t|<|dur(t|dS)Nz$reduction functions must be callable)callable TypeErrordispatch_tabler)ob_typepickle_functionconstructor_obr ,/opt/alt/python39/lib64/python3.9/copyreg.pyr s rcCst|stddS)Nzconstructors must be callable)rr)objectr r r rsrcCst|j|jffSN)complexrealimag)cr r r pickle_complex"srcCs<|turt|}n$|||}|jtjkr8||||Sr)r__new____init__)clsbasestateobjr r r _reconstructor)s     ric Cs|dks J|j}|jD]:}t|dr4|jt@s4qX|j}t|tr|j|urqXqt }|t urfd}n"||urt d|j d||}|||f}z |j }WnXt yt|ddrt d|j d|dz |j}Wnt yd}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__AttributeErrorgetattr__dict__r) selfprotorrnewrargsgetstatedictr r r _reduce_ex7s@          r1cGs|j|g|RSrr)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|jd}|dur|Sg}t|ds(n|jD]}d|jvr.|jd}t|trV|f}|D]^}|dvrjqZqZ|dr|ds|j d}|r| d||fq| |qZ| |qZq.z ||_ Wn Yn0|S)aReturn 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 startswithendswithr&lstripappendr6)rnamesrslotsnamestrippedr r r _slotnamesgs2         rDcCst|}d|krdks&ntd||f}t||krNt||krNdS|tvrjtd|t|f|tvrtd|t|f|t|<|t|<dS)zRegister an extension code.izcode 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_registrymodulerBcodekeyr r r rs$   rcCsR||f}t||ks$t||kr4td||ft|=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 rs rcCs tdSr)rNclearr r r r rsr)N)__doc____all__rrrr NameErrorrrr"typerFrr$r1r3r5rDrHrIrNrrrr r r r s.     '<