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.
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 61c9428..3ec5a00 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -38,9 +38,9 @@
io = PyImport_ImportModule("_io");
if (io == NULL)
return NULL;
- stream = _PyObject_CallMethodId(io, &PyId_open, "isisssi", fd, mode,
+ stream = _PyObject_CallMethodId(io, &PyId_open, "isisssO", fd, mode,
buffering, encoding, errors,
- newline, closefd);
+ newline, closefd ? Py_True : Py_False);
Py_DECREF(io);
if (stream == NULL)
return NULL;