This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients corona10, eric.smith, petr.viktorin, rhettinger, serhiy.storchaka, vstinner
Date 2022-03-28.15:56:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1648482990.53.0.187572555724.issue47143@roundup.psfhosted.org>
In-reply-to
Content
pickle.dump(x) checks if x is a type since commit f048a8f6d79173cc1da1bf12c60ae06fea36762c (March 2002) of bpo-494904:

    Pickler.save(): Fix for SF bug #494904: Cannot pickle a class with a
    metaclass, reported by Dan Parisien.

+            if issubclass(t, TypeType):
+                self.save_global(object)
+                return

Followed by a minor fix: commit 85ee491b3af3e1c124522249a52443b4d8c34c88 of bpo-502085:

    Don't die when issubclass(t, TypeType) fails.


-            if issubclass(t, TypeType):
+            try:
+                issc = issubclass(t, TypeType)
+            except TypeError: # t is not a class
+                issc = 0

copy.deepcopy(x) returns x if it's a type since commit 11ade1ddc053dcec884e2431b55fb1c1727c65d7 (June 2002) of bpo-560794.

    SF patch 560794 (Greg Chapman): deepcopy can't handle custom
    metaclasses.

         try:
-            copier = x.__deepcopy__
-        except AttributeError:
+            issc = issubclass(type(x), type)
+        except TypeError:
+            issc = 0
+        if issc:
+            y = _deepcopy_dispatch[type](x, memo)
+        else:
             (...)
History
Date User Action Args
2022-03-28 15:56:30vstinnersetrecipients: + vstinner, rhettinger, eric.smith, petr.viktorin, serhiy.storchaka, corona10
2022-03-28 15:56:30vstinnersetmessageid: <1648482990.53.0.187572555724.issue47143@roundup.psfhosted.org>
2022-03-28 15:56:30vstinnerlinkissue47143 messages
2022-03-28 15:56:30vstinnercreate