summaryrefslogtreecommitdiffstats
path: root/Lib/pickle.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-03-31 10:12:37 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-03-31 10:12:37 (GMT)
commitbfe1824d08fb107768ce17dd4de6c7f879935098 (patch)
tree8fb65d4b1a5cdc6ff13fb73fc58e5198750b3ae2 /Lib/pickle.py
parentc43a666ba2664d686387a8c4feb51aec868d06fe (diff)
downloadcpython-bfe1824d08fb107768ce17dd4de6c7f879935098.zip
cpython-bfe1824d08fb107768ce17dd4de6c7f879935098.tar.gz
cpython-bfe1824d08fb107768ce17dd4de6c7f879935098.tar.bz2
Issue #18473: Fixed 2to3 and 3to2 compatible pickle mappings.
Fixed ambigious reverse mappings. Added many new mappings. Import mapping is no longer applied to modules already mapped with full name mapping. Added tests for compatible pickling and unpickling and for consistency of _compat_pickle mappings.
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 e38ecac..67382ae 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -944,7 +944,7 @@ class _Pickler:
r_import_mapping = _compat_pickle.REVERSE_IMPORT_MAPPING
if (module_name, name) in r_name_mapping:
module_name, name = r_name_mapping[(module_name, name)]
- if module_name in r_import_mapping:
+ elif module_name in r_import_mapping:
module_name = r_import_mapping[module_name]
try:
write(GLOBAL + bytes(module_name, "ascii") + b'\n' +
@@ -1370,7 +1370,7 @@ class _Unpickler:
if self.proto < 3 and self.fix_imports:
if (module, name) in _compat_pickle.NAME_MAPPING:
module, name = _compat_pickle.NAME_MAPPING[(module, name)]
- if module in _compat_pickle.IMPORT_MAPPING:
+ elif module in _compat_pickle.IMPORT_MAPPING:
module = _compat_pickle.IMPORT_MAPPING[module]
__import__(module, level=0)
return _getattribute(sys.modules[module], name,