From ffd41d9f101e31973b8713e884c95118fceb6f59 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Tue, 4 Oct 2011 09:23:04 +0200 Subject: =?UTF-8?q?Issue=20#7689:=20Allow=20pickling=20of=20dynamically=20?= =?UTF-8?q?created=20classes=20when=20their=20metaclass=20is=20registered?= =?UTF-8?q?=20with=20copyreg.=20=20Patch=20by=20Nicolas=20M.=20Thi=C3=A9ry?= =?UTF-8?q?=20and=20Craig=20Citro.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lib/pickle.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'Lib/pickle.py') diff --git a/Lib/pickle.py b/Lib/pickle.py index 32ae02bc7d..c770ff8bdf 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -299,20 +299,20 @@ class _Pickler: f(self, obj) # Call unbound method with explicit self return - # Check for a class with a custom metaclass; treat as regular class - try: - issc = issubclass(t, type) - except TypeError: # t is not a class (old Boost; see SF #502085) - issc = 0 - if issc: - self.save_global(obj) - return - # Check copyreg.dispatch_table reduce = dispatch_table.get(t) if reduce: rv = reduce(obj) else: + # Check for a class with a custom metaclass; treat as regular class + try: + issc = issubclass(t, type) + except TypeError: # t is not a class (old Boost; see SF #502085) + issc = False + if issc: + self.save_global(obj) + return + # Check for a __reduce_ex__ method, fall back to __reduce__ reduce = getattr(obj, "__reduce_ex__", None) if reduce: -- cgit v1.2.1