o ?Og@sdZgdZiZdddZddZzeWn eyYn wddZeeeed d Zee e e Bed d Z d Z e e jZddZddZddZddZiZiZiZddZddZddZdS)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_cacheNcCs0t|std|t|<|durt|dSdS)Nz$reduction functions must be callable)callable TypeErrordispatch_tabler)ob_typepickle_functionconstructor_obr ./opt/alt/python310/lib64/python3.10/copyreg.pyr s  rcCst|stddS)Nzconstructors must be callable)rr)objectr r r rsrcCst|j|jffSN)complexrealimag)cr r r pickle_complex"srcCs"ddl}ddl}|j|j|jffS)N) functoolsoperatorreduceor___args__)objrrr r r pickle_union'srcCs>|tur t|}|S|||}|jtjkr||||Sr)r__new____init__)clsbasestaterr r r _reconstructor/s   r"ic Cs|j}|jD]}t|dr|jt@sn|j}t|tr#|j|ur#nqt }|t ur-d}n||ur:t d|j d||}|||f}z|j }Wn,t ytt|ddrat d|j d|dz|j}Wn t yqd}YnwYnw|}|rt||fSt|fS)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") selfprotorr newr!argsgetstatedictr r r _reduce_ex=sF          r7cGs|j|g|RSrr)rr4r r r __newobj__dsr9cCs|j|g|Ri|S)zUsed by pickle protocol 4, instead of __newobj__ to allow classes with keyword-only arguments to be pickled correctly. r8)rr4kwargsr r r __newobj_ex__gsr;cCs|jd}|dur |Sg}t|dsnI|jD]E}d|jvr\|jd}t|tr+|f}|D].}|dvr4q-|drV|dsV|j d}|rP| d||fq-| |q-| |q-qz||_ W|SY|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$)r0 __weakref_____z_%s%s) r0getr'r&r)str startswithendswithr,lstripappendr<)rnamesrslotsnamestrippedr r r _slotnamesms6         rJcCst|}d|krdkstdtd||f}t||kr*t||kr*dS|tvr8td|t|f|tvrFtd|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_registrymodulerHcodekeyr r r rs&   rcCsV||f}t||kst||krtd||ft|=t|=|tvr)t|=dSdS)z0Unregister an extension code. For testing only.z%key %s is not registered with code %sN)rNr@rOrM_extension_cacherPr r r rs rcCs tdSr)rTclearr r r r rs rr)__doc____all__rrrr NameErrorrrtyperLrAr"r(rr*r7r9r;rJrNrOrTrrrr r r r s6     '<