diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-10-04 07:34:48 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-10-04 07:34:48 (GMT) |
commit | 561a821e93dc5c5aff9c5e26a3cbe482ac154a51 (patch) | |
tree | 48531cf43575f3e9a5496006bebbdd03cfd27e19 /Lib/pickle.py | |
parent | ad349a190e923b32e7ef43ddafffde93df75051a (diff) | |
download | cpython-561a821e93dc5c5aff9c5e26a3cbe482ac154a51.zip cpython-561a821e93dc5c5aff9c5e26a3cbe482ac154a51.tar.gz cpython-561a821e93dc5c5aff9c5e26a3cbe482ac154a51.tar.bz2 |
Issue #7689: Allow pickling of dynamically created classes when their
metaclass is registered with copyreg. Patch by Nicolas M. ThiƩry and
Craig Citro.
Diffstat (limited to 'Lib/pickle.py')
-rw-r--r-- | Lib/pickle.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py index 005b1b9..5b95cba 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -286,20 +286,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, TypeType) - except TypeError: # t is not a class (old Boost; see SF #502085) - issc = 0 - if issc: - self.save_global(obj) - return - # Check copy_reg.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, TypeType) + except TypeError: # t is not a class (old Boost; see SF #502085) + issc = 0 + 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: |