summaryrefslogtreecommitdiffstats
path: root/Modules/_io/textio.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-09-01 09:16:51 (GMT)
committerGitHub <noreply@github.com>2019-09-01 09:16:51 (GMT)
commit1f21eaa15e8a0d2b0f78d0e3f2b9e5b458eb0a70 (patch)
tree8db3de2421c1d45d018a7a1dc03f42a0797acee2 /Modules/_io/textio.c
parent5eca7f3f3836cc734dfe8dc5ec669f3b4e9333fe (diff)
downloadcpython-1f21eaa15e8a0d2b0f78d0e3f2b9e5b458eb0a70.zip
cpython-1f21eaa15e8a0d2b0f78d0e3f2b9e5b458eb0a70.tar.gz
cpython-1f21eaa15e8a0d2b0f78d0e3f2b9e5b458eb0a70.tar.bz2
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.
Diffstat (limited to 'Modules/_io/textio.c')
-rw-r--r--Modules/_io/textio.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
index 7ddac80..1db8d94 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -880,9 +880,9 @@ _textiowrapper_set_decoder(textio *self, PyObject *codec_info,
return -1;
if (self->readuniversal) {
- PyObject *incrementalDecoder = PyObject_CallFunction(
+ PyObject *incrementalDecoder = PyObject_CallFunctionObjArgs(
(PyObject *)&PyIncrementalNewlineDecoder_Type,
- "Oi", self->decoder, (int)self->readtranslate);
+ self->decoder, self->readtranslate ? Py_True : Py_False, NULL);
if (incrementalDecoder == NULL)
return -1;
Py_CLEAR(self->decoder);
@@ -2591,8 +2591,8 @@ _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence)
}
Py_XSETREF(self->snapshot, snapshot);
- decoded = _PyObject_CallMethodId(self->decoder, &PyId_decode,
- "Oi", input_chunk, (int)cookie.need_eof);
+ decoded = _PyObject_CallMethodIdObjArgs(self->decoder, &PyId_decode,
+ input_chunk, cookie.need_eof ? Py_True : Py_False, NULL);
if (check_decoded(decoded) < 0)
goto fail;
@@ -2819,7 +2819,7 @@ _io_TextIOWrapper_tell_impl(textio *self)
if (input == input_end) {
/* We didn't get enough decoded data; signal EOF to get more. */
PyObject *decoded = _PyObject_CallMethodId(
- self->decoder, &PyId_decode, "yi", "", /* final = */ 1);
+ self->decoder, &PyId_decode, "yO", "", /* final = */ Py_True);
if (check_decoded(decoded) < 0)
goto fail;
chars_decoded += PyUnicode_GET_LENGTH(decoded);