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|dksJ|j}|jD]}t|dr|jt@sn|j}t|tr)|j|ur)nq t }|t ur3d}n||ur@t d|j d||}|||f}z|j }Wn,t yzt|ddrgt d|j d|dz|j}Wn t ywd}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=sH           r8cGs|j|g|RSrr)rr5r r r __newobj__dsr:cCs|j|g|Ri|S)zUsed by pickle protocol 4, instead of __newobj__ to allow classes with keyword-only arguments to be pickled correctly. r9)rr5kwargsr 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%)r1 __weakref_____z_%s%s) r1getr(r'r*str startswithendswithr-lstripappendr=)rnamesrslotsnamestrippedr r r _slotnamesms6         rKcCst|}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_registryrA_inverted_registrymodulerIcodekeyr 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)rOrArPrN_extension_cacherQr r r rs rcCs tdSr)rUclearr r r r rs rr)__doc____all__rrrr NameErrorrrtyperMrBr"r)rr+r8r:r<rKrOrPrUrrrr r r r s6     '<