summaryrefslogtreecommitdiff
path: root/Lib/pickle.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-03-04 18:31:48 +0100
committerAntoine Pitrou <solipsis@pitrou.net>2012-03-04 18:31:48 +0100
commit8d3c290de4de275fc725b116050ea9d109af1ba8 (patch)
treec86d3605279163460a7424a6b400dd851f50bb56 /Lib/pickle.py
parentd1c351d39c8468daea1ece05c3a1b255f064f96f (diff)
downloadcpython-git-8d3c290de4de275fc725b116050ea9d109af1ba8.tar.gz
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.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py
index c01a6af807..20b3646a5b 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: