mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
gh-112068: C API: Add support of nullable arguments in PyArg_Parse (GH-121303)
This commit is contained in:
parent
8421b648e9
commit
f5f1ac84b3
11 changed files with 324 additions and 142 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue