diff options
| author | Antoine Pitrou <solipsis@pitrou.net> | 2011-10-04 09:25:28 +0200 |
|---|---|---|
| committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-10-04 09:25:28 +0200 |
| commit | 5a688dbf97f1537d3f2309bfe6be93dab2f10ce0 (patch) | |
| tree | 669b73365df94fcb787c7dfe0edaf43e9e4a33d6 /Lib/pickle.py | |
| parent | 29f43f7368115c47c97acff02816a680c3ebd73e (diff) | |
| parent | ffd41d9f101e31973b8713e884c95118fceb6f59 (diff) | |
| download | cpython-git-5a688dbf97f1537d3f2309bfe6be93dab2f10ce0.tar.gz | |
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 0aee77af77..a5c8328c13 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -297,20 +297,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: |
