i f @sdZdddddgZiZdddZddZyeWnek rXYnXd d Zeeeed d ZdZ ddZ ddZ ddZ ddZ iZiZiZddZddZddZdS)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_cacheNcCsBt|stdn|t|<|dk r>t|ndS)Nz$reduction functions must be callable)callable TypeErrordispatch_tabler)ob_typepickle_functionconstructor_obr ,/opt/alt/python34/lib64/python3.4/copyreg.pyr s    cCst|stdndS)Nzconstructors must be callable)rr)objectr r r rs cCst|j|jffS)N)complexrealimag)cr r r pickle_complex"srcCsY|tkrtj|}n7|j||}|jtjkrU|j||n|S)N)r__new____init__)clsbasestateobjr r r _reconstructor)s  r cCs+x;|jjD]'}t|dr |jt@ r Pq q Wt}|tkrSd}n1||jkrxtd|jn||}|j||f}y |j}Wn[t k rt |ddrtdny |j }Wnt k rd}YnXYn X|}|rt ||fSt |fSdS)N __flags__zcan't pickle %s objects __slots__zNa class that defines __slots__ without defining __getstate__ cannot be pickled) __class____mro__hasattrr _HEAPTYPErr__name__ __getstate__AttributeErrorgetattr__dict__r)selfprotorrargsgetstatedictr r r _reduce_ex6s.         r-cGs|j||S)N)r)rr*r r r __newobj__Wsr.cCs|j|||S)zUsed by pickle protocol 4, instead of __newobj__ to allow classes with keyword-only arguments to be pickled correctly. )r)rr*kwargsr r r __newobj_ex__Zsr0c Cs|jjd}|dk r"|Sg}t|ds:nx|jD]}d|jkrD|jd}t|tr|f}nxl|D]a}|dkrqq|jdr|jd r|jd|j |fq|j|qWqDqDWy ||_ WnYnX|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__Nrr' __weakref____z_%s%s)z__dict__z __weakref__) r'getr!r isinstancestr startswithendswithappendr#r1)rnamesrslotsnamer r r _slotnames`s,       r=cCst|}d|ko#dkns7tdn||f}tj||krqtj||krqdS|tkrtd|t|fn|tkrtd|t|fn|t|<|t|s.     !   8