summaryrefslogtreecommitdiffstats
path: root/Modules/_elementtree.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_elementtree.c')
-rw-r--r--Modules/_elementtree.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index edd2f88..aaa0cad 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -372,33 +372,27 @@ element_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject*
get_attrib_from_keywords(PyObject *kwds)
{
- PyObject *attrib_str = PyUnicode_FromString("attrib");
- if (attrib_str == NULL) {
+ PyObject *attrib;
+ if (PyDict_PopString(kwds, "attrib", &attrib) < 0) {
return NULL;
}
- PyObject *attrib = PyDict_GetItemWithError(kwds, attrib_str);
if (attrib) {
/* If attrib was found in kwds, copy its value and remove it from
* kwds
*/
if (!PyDict_Check(attrib)) {
- Py_DECREF(attrib_str);
PyErr_Format(PyExc_TypeError, "attrib must be dict, not %.100s",
Py_TYPE(attrib)->tp_name);
+ Py_DECREF(attrib);
return NULL;
}
- attrib = PyDict_Copy(attrib);
- if (attrib && PyDict_DelItem(kwds, attrib_str) < 0) {
- Py_SETREF(attrib, NULL);
- }
+ Py_SETREF(attrib, PyDict_Copy(attrib));
}
- else if (!PyErr_Occurred()) {
+ else {
attrib = PyDict_New();
}
- Py_DECREF(attrib_str);
-
if (attrib != NULL && PyDict_Update(attrib, kwds) < 0) {
Py_DECREF(attrib);
return NULL;