diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-03-04 17:31:48 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-03-04 17:31:48 (GMT) |
commit | 8d3c290de4de275fc725b116050ea9d109af1ba8 (patch) | |
tree | c86d3605279163460a7424a6b400dd851f50bb56 /Lib/pickle.py | |
parent | d1c351d39c8468daea1ece05c3a1b255f064f96f (diff) | |
download | cpython-8d3c290de4de275fc725b116050ea9d109af1ba8.zip cpython-8d3c290de4de275fc725b116050ea9d109af1ba8.tar.gz cpython-8d3c290de4de275fc725b116050ea9d109af1ba8.tar.bz2 |
Issue #14166: Pickler objects now have an optional `dispatch_table` attribute which allows to set custom per-pickler reduction functions.
Patch by sbt.
Diffstat (limited to 'Lib/pickle.py')
-rw-r--r-- | Lib/pickle.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py index c01a6af..20b3646 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -297,8 +297,8 @@ class _Pickler: f(self, obj) # Call unbound method with explicit self return - # Check copyreg.dispatch_table - reduce = dispatch_table.get(t) + # Check private dispatch table if any, or else copyreg.dispatch_table + reduce = getattr(self, 'dispatch_table', dispatch_table).get(t) if reduce: rv = reduce(obj) else: |