summaryrefslogtreecommitdiffstats
path: root/Modules/_pickle.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_pickle.c')
-rw-r--r--Modules/_pickle.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index a68a0aa..5ecf7ca 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -4438,16 +4438,13 @@ save(PickleState *st, PicklerObject *self, PyObject *obj, int pers_save)
PyObject_GetItem and _PyObject_GetAttrId used below. */
Py_INCREF(reduce_func);
}
- } else {
- reduce_func = PyObject_GetItem(self->dispatch_table,
- (PyObject *)type);
- if (reduce_func == NULL) {
- if (PyErr_ExceptionMatches(PyExc_KeyError))
- PyErr_Clear();
- else
- goto error;
- }
}
+ else if (PyMapping_GetOptionalItem(self->dispatch_table, (PyObject *)type,
+ &reduce_func) < 0)
+ {
+ goto error;
+ }
+
if (reduce_func != NULL) {
reduce_value = _Pickle_FastCall(reduce_func, Py_NewRef(obj));
}