summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/pyexpat.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index 21579a8..9d95309 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -240,19 +240,12 @@ string_intern(xmlparseobject *self, const char* str)
return result;
if (!self->intern)
return result;
- value = PyDict_GetItemWithError(self->intern, result);
- if (!value) {
- if (!PyErr_Occurred() &&
- PyDict_SetItem(self->intern, result, result) == 0)
- {
- return result;
- }
- else {
- Py_DECREF(result);
- return NULL;
- }
+ if (PyDict_GetItemRef(self->intern, result, &value) == 0 &&
+ PyDict_SetItem(self->intern, result, result) == 0)
+ {
+ return result;
}
- Py_INCREF(value);
+ assert((value != NULL) == !PyErr_Occurred());
Py_DECREF(result);
return value;
}