From bfe1824d08fb107768ce17dd4de6c7f879935098 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Tue, 31 Mar 2015 13:12:37 +0300 Subject: 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. --- Lib/pickle.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Lib/pickle.py') diff --git a/Lib/pickle.py b/Lib/pickle.py index e38ecac824..67382aee92 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, -- cgit v1.2.1