(obj)
| 748 | |
| 749 | |
| 750 | def _class_getstate(obj): |
| 751 | clsdict = _extract_class_dict(obj) |
| 752 | clsdict.pop("__weakref__", None) |
| 753 | |
| 754 | if issubclass(type(obj), abc.ABCMeta): |
| 755 | # If obj is an instance of an ABCMeta subclass, don't pickle the |
| 756 | # cache/negative caches populated during isinstance/issubclass |
| 757 | # checks, but pickle the list of registered subclasses of obj. |
| 758 | clsdict.pop("_abc_cache", None) |
| 759 | clsdict.pop("_abc_negative_cache", None) |
| 760 | clsdict.pop("_abc_negative_cache_version", None) |
| 761 | registry = clsdict.pop("_abc_registry", None) |
| 762 | if registry is None: |
| 763 | # The abc caches and registered subclasses of a |
| 764 | # class are bundled into the single _abc_impl attribute |
| 765 | clsdict.pop("_abc_impl", None) |
| 766 | (registry, _, _, _) = abc._get_dump(obj) |
| 767 | |
| 768 | clsdict["_abc_impl"] = [subclass_weakref() for subclass_weakref in registry] |
| 769 | else: |
| 770 | # In the above if clause, registry is a set of weakrefs -- in |
| 771 | # this case, registry is a WeakSet |
| 772 | clsdict["_abc_impl"] = [type_ for type_ in registry] |
| 773 | |
| 774 | if "__slots__" in clsdict: |
| 775 | # pickle string length optimization: member descriptors of obj are |
| 776 | # created automatically from obj's __slots__ attribute, no need to |
| 777 | # save them in obj's state |
| 778 | if isinstance(obj.__slots__, str): |
| 779 | clsdict.pop(obj.__slots__) |
| 780 | else: |
| 781 | for k in obj.__slots__: |
| 782 | clsdict.pop(k, None) |
| 783 | |
| 784 | clsdict.pop("__dict__", None) # unpicklable property object |
| 785 | |
| 786 | if sys.version_info >= (3, 14): |
| 787 | # PEP-649/749: __annotate_func__ contains a closure that references the class |
| 788 | # dict. We need to exclude it from pickling. Python will recreate it when |
| 789 | # __annotations__ is accessed at unpickling time. |
| 790 | clsdict.pop("__annotate_func__", None) |
| 791 | |
| 792 | return (clsdict, {}) |
| 793 | |
| 794 | |
| 795 | def _enum_getstate(obj): |
no test coverage detected
searching dependent graphs…