[3.14] Revert "gh-112068: C API: Add support of nullable arguments in PyArg_Parse (GH-121303)" (GH-136991) (#137006)

This commit is contained in:
Serhiy Storchaka 2025-07-22 19:16:31 +03:00 committed by GitHub
parent c328d140eb
commit 805daa2edb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 144 additions and 322 deletions

View file

@ -1228,16 +1228,23 @@ encoder_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static char *kwlist[] = {"markers", "default", "encoder", "indent", "key_separator", "item_separator", "sort_keys", "skipkeys", "allow_nan", NULL};
PyEncoderObject *s;
PyObject *markers = Py_None, *defaultfn, *encoder, *indent, *key_separator;
PyObject *markers, *defaultfn, *encoder, *indent, *key_separator;
PyObject *item_separator;
int sort_keys, skipkeys, allow_nan;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!?OOOUUppp:make_encoder", kwlist,
&PyDict_Type, &markers, &defaultfn, &encoder, &indent,
if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOOOUUppp:make_encoder", kwlist,
&markers, &defaultfn, &encoder, &indent,
&key_separator, &item_separator,
&sort_keys, &skipkeys, &allow_nan))
return NULL;
if (markers != Py_None && !PyDict_Check(markers)) {
PyErr_Format(PyExc_TypeError,
"make_encoder() argument 1 must be dict or None, "
"not %.200s", Py_TYPE(markers)->tp_name);
return NULL;
}
s = (PyEncoderObject *)type->tp_alloc(type, 0);
if (s == NULL)
return NULL;