gh-112068: C API: Add support of nullable arguments in PyArg_Parse (GH-121303)

This commit is contained in:
Serhiy Storchaka 2025-04-08 22:08:00 +03:00 committed by GitHub
parent 8421b648e9
commit f5f1ac84b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 324 additions and 142 deletions

View file

@ -1252,14 +1252,11 @@ interp_get_config(PyObject *self, PyObject *args, PyObject *kwds)
PyObject *idobj = NULL;
int restricted = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwds,
"O|$p:get_config", kwlist,
"O?|$p:get_config", kwlist,
&idobj, &restricted))
{
return NULL;
}
if (idobj == Py_None) {
idobj = NULL;
}
int reqready = 0;
PyInterpreterState *interp = \
@ -1376,14 +1373,14 @@ capture_exception(PyObject *self, PyObject *args, PyObject *kwds)
static char *kwlist[] = {"exc", NULL};
PyObject *exc_arg = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwds,
"|O:capture_exception", kwlist,
"|O?:capture_exception", kwlist,
&exc_arg))
{
return NULL;
}
PyObject *exc = exc_arg;
if (exc == NULL || exc == Py_None) {
if (exc == NULL) {
exc = PyErr_GetRaisedException();
if (exc == NULL) {
Py_RETURN_NONE;