diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2014-12-01 23:20:03 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2014-12-01 23:20:03 (GMT) |
commit | 6cd5eda0dd4c574c84c9e6b1ad0a7eefc03fbea3 (patch) | |
tree | 39e1a6f096c4c9dded7c37955f369f65edb68339 /Modules/_pickle.c | |
parent | 6f3eb39968d08bcb140f34d85d2a803434917bab (diff) | |
download | cpython-6cd5eda0dd4c574c84c9e6b1ad0a7eefc03fbea3.zip cpython-6cd5eda0dd4c574c84c9e6b1ad0a7eefc03fbea3.tar.gz cpython-6cd5eda0dd4c574c84c9e6b1ad0a7eefc03fbea3.tar.bz2 |
Fix uninitialized variable after #22676.
Diffstat (limited to 'Modules/_pickle.c')
-rw-r--r-- | Modules/_pickle.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c index a13eff3..ecf0c6c 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -1547,10 +1547,16 @@ get_dotted_path(PyObject *obj, PyObject *name, int allow_qualname) { n = PyList_GET_SIZE(dotted_path); assert(n >= 1); if (!allow_qualname && n > 1) { - PyErr_Format(PyExc_AttributeError, - "Can't get qualified attribute %R on %R;" - "use protocols >= 4 to enable support", - name, obj); + if (obj == NULL) + PyErr_Format(PyExc_AttributeError, + "Can't pickle qualified object %R; " + "use protocols >= 4 to enable support", + name); + else + PyErr_Format(PyExc_AttributeError, + "Can't pickle qualified attribute %R on %R; " + "use protocols >= 4 to enable support", + name, obj); Py_DECREF(dotted_path); return NULL; } @@ -1562,8 +1568,12 @@ get_dotted_path(PyObject *obj, PyObject *name, int allow_qualname) { assert(PyBool_Check(result)); Py_DECREF(result); if (is_equal) { - PyErr_Format(PyExc_AttributeError, - "Can't get local attribute %R on %R", name, obj); + if (obj == NULL) + PyErr_Format(PyExc_AttributeError, + "Can't pickle local object %R", name); + else + PyErr_Format(PyExc_AttributeError, + "Can't pickle local attribute %R on %R", name, obj); Py_DECREF(dotted_path); return NULL; } @@ -1653,7 +1663,7 @@ whichmodule(PyObject *global, PyObject *global_name, int allow_qualname) return NULL; } - dotted_path = get_dotted_path(module, global_name, allow_qualname); + dotted_path = get_dotted_path(NULL, global_name, allow_qualname); if (dotted_path == NULL) return NULL; |