gh-112438: Fix support of format units with the "e" prefix in nested tuples in PyArg_Parse (gh-112439)

This commit is contained in:
Serhiy Storchaka 2023-11-27 19:32:55 +02:00 • committed by GitHub
parent 812360fddd
commit 4eea1e8236
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 6 deletions

View file

@ -71,18 +71,22 @@ parse_tuple_and_keywords(PyObject *self, PyObject *args)
if (result) {
int objects_only = 1;
int count = 0;
for (const char *f = sub_format; *f; f++) {
if (Py_ISALNUM(*f) && strchr("OSUY", *f) == NULL) {
objects_only = 0;
break;
if (Py_ISALNUM(*f)) {
if (strchr("OSUY", *f) == NULL) {
objects_only = 0;
break;
}
count++;
}
}
if (objects_only) {
return_value = PyTuple_New(size);
return_value = PyTuple_New(count);
if (return_value == NULL) {
goto exit;
}
for (Py_ssize_t i = 0; i < size; i++) {
for (Py_ssize_t i = 0; i < count; i++) {
PyObject *arg = *(PyObject **)(buffers + i);
if (arg == NULL) {
arg = Py_None;