mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
bpo-15999: Clean up of handling boolean arguments. (GH-15610)
* Use the 'p' format unit instead of manually called PyObject_IsTrue(). * Pass boolean value instead 0/1 integers to functions that needs boolean. * Convert some arguments to boolean only once.
This commit is contained in:
parent
5eca7f3f38
commit
1f21eaa15e
21 changed files with 69 additions and 78 deletions
|
@ -1080,25 +1080,20 @@ parser__pickler(PyObject *self, PyObject *args)
|
|||
NOTE(ARGUNUSED(self))
|
||||
PyObject *result = NULL;
|
||||
PyObject *st = NULL;
|
||||
PyObject *empty_dict = NULL;
|
||||
|
||||
if (PyArg_ParseTuple(args, "O!:_pickler", &PyST_Type, &st)) {
|
||||
PyObject *newargs;
|
||||
PyObject *tuple;
|
||||
|
||||
if ((empty_dict = PyDict_New()) == NULL)
|
||||
goto finally;
|
||||
if ((newargs = Py_BuildValue("Oi", st, 1)) == NULL)
|
||||
goto finally;
|
||||
tuple = parser_st2tuple((PyST_Object*)NULL, newargs, empty_dict);
|
||||
if ((newargs = PyTuple_Pack(2, st, Py_True)) == NULL)
|
||||
return NULL;
|
||||
tuple = parser_st2tuple((PyST_Object*)NULL, newargs, NULL);
|
||||
if (tuple != NULL) {
|
||||
result = Py_BuildValue("O(O)", pickle_constructor, tuple);
|
||||
Py_DECREF(tuple);
|
||||
}
|
||||
Py_DECREF(newargs);
|
||||
}
|
||||
finally:
|
||||
Py_XDECREF(empty_dict);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue