mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +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
|
@ -651,12 +651,12 @@ PyThreadHandleObject_join(PyObject *op, PyObject *args)
|
|||
PyThreadHandleObject *self = PyThreadHandleObject_CAST(op);
|
||||
|
||||
PyObject *timeout_obj = NULL;
|
||||
if (!PyArg_ParseTuple(args, "|O:join", &timeout_obj)) {
|
||||
if (!PyArg_ParseTuple(args, "|O?:join", &timeout_obj)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyTime_t timeout_ns = -1;
|
||||
if (timeout_obj != NULL && timeout_obj != Py_None) {
|
||||
if (timeout_obj != NULL) {
|
||||
if (_PyTime_FromSecondsObject(&timeout_ns, timeout_obj,
|
||||
_PyTime_ROUND_TIMEOUT) < 0) {
|
||||
return NULL;
|
||||
|
@ -1919,10 +1919,10 @@ thread_PyThread_start_joinable_thread(PyObject *module, PyObject *fargs,
|
|||
PyObject *func = NULL;
|
||||
int daemon = 1;
|
||||
thread_module_state *state = get_thread_state(module);
|
||||
PyObject *hobj = NULL;
|
||||
PyObject *hobj = Py_None;
|
||||
if (!PyArg_ParseTupleAndKeywords(fargs, fkwargs,
|
||||
"O|Op:start_joinable_thread", keywords,
|
||||
&func, &hobj, &daemon)) {
|
||||
"O|O!?p:start_joinable_thread", keywords,
|
||||
&func, state->thread_handle_type, &hobj, &daemon)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1932,14 +1932,6 @@ thread_PyThread_start_joinable_thread(PyObject *module, PyObject *fargs,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (hobj == NULL) {
|
||||
hobj = Py_None;
|
||||
}
|
||||
else if (hobj != Py_None && !Py_IS_TYPE(hobj, state->thread_handle_type)) {
|
||||
PyErr_SetString(PyExc_TypeError, "'handle' must be a _ThreadHandle");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (PySys_Audit("_thread.start_joinable_thread", "OiO", func, daemon,
|
||||
hobj) < 0) {
|
||||
return NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue