Skip to content

Commit a2a0428

Browse files
committed
remove critical section for keywords
1 parent 6c786a5 commit a2a0428

1 file changed

Lines changed: 3 additions & 14 deletions

File tree

Modules/_functoolsmodule.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -194,20 +194,13 @@ partial_new(PyTypeObject *type, PyObject *args, PyObject *kw)
194194
if (kw != NULL) {
195195
PyObject *key, *val;
196196
Py_ssize_t pos = 0;
197-
int error = 0;
198-
Py_BEGIN_CRITICAL_SECTION(kw);
199197
while (PyDict_Next(kw, &pos, &key, &val)) {
200198
if (val == phold) {
201-
error = 1;
202-
break;
199+
PyErr_SetString(PyExc_TypeError,
200+
"Placeholder cannot be passed as a keyword argument");
201+
return NULL;
203202
}
204203
}
205-
Py_END_CRITICAL_SECTION();
206-
if (error) {
207-
PyErr_SetString(PyExc_TypeError,
208-
"Placeholder cannot be passed as a keyword argument");
209-
return NULL;
210-
}
211204
}
212205

213206
/* check wrapped function / object */
@@ -1264,12 +1257,10 @@ lru_cache_make_key(PyObject *kwd_mark, PyObject *args,
12641257
}
12651258
if (kwds_size) {
12661259
PyTuple_SET_ITEM(key, key_pos++, Py_NewRef(kwd_mark));
1267-
Py_BEGIN_CRITICAL_SECTION(kwds);
12681260
for (pos = 0; PyDict_Next(kwds, &pos, &keyword, &value);) {
12691261
PyTuple_SET_ITEM(key, key_pos++, Py_NewRef(keyword));
12701262
PyTuple_SET_ITEM(key, key_pos++, Py_NewRef(value));
12711263
}
1272-
Py_END_CRITICAL_SECTION();
12731264
assert(key_pos == PyTuple_GET_SIZE(args) + kwds_size * 2 + 1);
12741265
}
12751266
if (typed) {
@@ -1278,12 +1269,10 @@ lru_cache_make_key(PyObject *kwd_mark, PyObject *args,
12781269
PyTuple_SET_ITEM(key, key_pos++, Py_NewRef(item));
12791270
}
12801271
if (kwds_size) {
1281-
Py_BEGIN_CRITICAL_SECTION(kwds);
12821272
for (pos = 0; PyDict_Next(kwds, &pos, &keyword, &value);) {
12831273
PyObject *item = (PyObject *)Py_TYPE(value);
12841274
PyTuple_SET_ITEM(key, key_pos++, Py_NewRef(item));
12851275
}
1286-
Py_END_CRITICAL_SECTION();
12871276
}
12881277
}
12891278
assert(key_pos == key_size);

0 commit comments

Comments
 (0)