summaryrefslogtreecommitdiffstats
path: root/Modules
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 /Modules
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 'Modules')
-rw-r--r--Modules/_pickle.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 10eb513..435cbae 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -3026,6 +3026,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;
@@ -6278,20 +6279,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;
}
}