diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-03-31 10:17:10 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-03-31 10:17:10 (GMT) |
commit | d5d818d40b9378488dc82150926e20e925acf7fe (patch) | |
tree | a6f28e009712c60a851bdb3326e6dd7385576e43 /Modules | |
parent | b6faf0dfa7e5d9f5b9f09bc1d1113069f1c962ab (diff) | |
parent | bfe1824d08fb107768ce17dd4de6c7f879935098 (diff) | |
download | cpython-d5d818d40b9378488dc82150926e20e925acf7fe.zip cpython-d5d818d40b9378488dc82150926e20e925acf7fe.tar.gz cpython-d5d818d40b9378488dc82150926e20e925acf7fe.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 'Modules')
-rw-r--r-- | Modules/_pickle.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 51e2f83..c1e2b40 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -3073,6 +3073,7 @@ fix_imports(PyObject **module_name, PyObject **global_name) Py_INCREF(fixed_global_name); *module_name = fixed_module_name; *global_name = fixed_global_name; + return 0; } else if (PyErr_Occurred()) { return -1; @@ -6324,20 +6325,21 @@ _pickle_Unpickler_find_class_impl(UnpicklerObject *self, PyObject *module_name, else if (PyErr_Occurred()) { return NULL; } - - /* Check if the module was renamed. */ - item = PyDict_GetItemWithError(st->import_mapping_2to3, module_name); - if (item) { - if (!PyUnicode_Check(item)) { - PyErr_Format(PyExc_RuntimeError, - "_compat_pickle.IMPORT_MAPPING values should be " - "strings, not %.200s", Py_TYPE(item)->tp_name); + else { + /* Check if the module was renamed. */ + item = PyDict_GetItemWithError(st->import_mapping_2to3, module_name); + if (item) { + if (!PyUnicode_Check(item)) { + PyErr_Format(PyExc_RuntimeError, + "_compat_pickle.IMPORT_MAPPING values should be " + "strings, not %.200s", Py_TYPE(item)->tp_name); + return NULL; + } + module_name = item; + } + else if (PyErr_Occurred()) { return NULL; } - module_name = item; - } - else if (PyErr_Occurred()) { - return NULL; } } |