summaryrefslogtreecommitdiffstats
path: root/Modules/_io/clinic
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-12-03 19:52:21 (GMT)
committerGitHub <noreply@github.com>2022-12-03 19:52:21 (GMT)
commita87c46eab3c306b1c5b8a072b7b30ac2c50651c0 (patch)
tree92c0ebdb6abd303ea967c0bd999d839a98f84494 /Modules/_io/clinic
parentc68573b339320409b038501fdd7d4f8a56766275 (diff)
downloadcpython-a87c46eab3c306b1c5b8a072b7b30ac2c50651c0.zip
cpython-a87c46eab3c306b1c5b8a072b7b30ac2c50651c0.tar.gz
cpython-a87c46eab3c306b1c5b8a072b7b30ac2c50651c0.tar.bz2
bpo-15999: Accept arbitrary values for boolean parameters. (#15609)
builtins and extension module functions and methods that expect boolean values for parameters now accept any Python object rather than just a bool or int type. This is more consistent with how native Python code itself behaves.
Diffstat (limited to 'Modules/_io/clinic')
-rw-r--r--Modules/_io/clinic/_iomodule.c.h6
-rw-r--r--Modules/_io/clinic/fileio.c.h6
-rw-r--r--Modules/_io/clinic/textio.c.h18
-rw-r--r--Modules/_io/clinic/winconsoleio.c.h6
4 files changed, 18 insertions, 18 deletions
diff --git a/Modules/_io/clinic/_iomodule.c.h b/Modules/_io/clinic/_iomodule.c.h
index b387384..4d76e33 100644
--- a/Modules/_io/clinic/_iomodule.c.h
+++ b/Modules/_io/clinic/_iomodule.c.h
@@ -280,8 +280,8 @@ _io_open(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw
}
}
if (args[6]) {
- closefd = _PyLong_AsInt(args[6]);
- if (closefd == -1 && PyErr_Occurred()) {
+ closefd = PyObject_IsTrue(args[6]);
+ if (closefd < 0) {
goto exit;
}
if (!--noptargs) {
@@ -407,4 +407,4 @@ _io_open_code(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec
exit:
return return_value;
}
-/*[clinic end generated code: output=1f8001287a423470 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=f387eba3f4c0254a input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/fileio.c.h b/Modules/_io/clinic/fileio.c.h
index a925b94..b6e9bd5 100644
--- a/Modules/_io/clinic/fileio.c.h
+++ b/Modules/_io/clinic/fileio.c.h
@@ -116,8 +116,8 @@ _io_FileIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
}
}
if (fastargs[2]) {
- closefd = _PyLong_AsInt(fastargs[2]);
- if (closefd == -1 && PyErr_Occurred()) {
+ closefd = PyObject_IsTrue(fastargs[2]);
+ if (closefd < 0) {
goto exit;
}
if (!--noptargs) {
@@ -466,4 +466,4 @@ _io_FileIO_isatty(fileio *self, PyObject *Py_UNUSED(ignored))
#ifndef _IO_FILEIO_TRUNCATE_METHODDEF
#define _IO_FILEIO_TRUNCATE_METHODDEF
#endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */
-/*[clinic end generated code: output=ff479a26cab0d479 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=27f883807a6c29ae input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/textio.c.h b/Modules/_io/clinic/textio.c.h
index 038f0a5..db968e8 100644
--- a/Modules/_io/clinic/textio.c.h
+++ b/Modules/_io/clinic/textio.c.h
@@ -68,8 +68,8 @@ _io_IncrementalNewlineDecoder___init__(PyObject *self, PyObject *args, PyObject
goto exit;
}
decoder = fastargs[0];
- translate = _PyLong_AsInt(fastargs[1]);
- if (translate == -1 && PyErr_Occurred()) {
+ translate = PyObject_IsTrue(fastargs[1]);
+ if (translate < 0) {
goto exit;
}
if (!noptargs) {
@@ -137,8 +137,8 @@ _io_IncrementalNewlineDecoder_decode(nldecoder_object *self, PyObject *const *ar
if (!noptargs) {
goto skip_optional_pos;
}
- final = _PyLong_AsInt(args[1]);
- if (final == -1 && PyErr_Occurred()) {
+ final = PyObject_IsTrue(args[1]);
+ if (final < 0) {
goto exit;
}
skip_optional_pos:
@@ -331,16 +331,16 @@ _io_TextIOWrapper___init__(PyObject *self, PyObject *args, PyObject *kwargs)
}
}
if (fastargs[4]) {
- line_buffering = _PyLong_AsInt(fastargs[4]);
- if (line_buffering == -1 && PyErr_Occurred()) {
+ line_buffering = PyObject_IsTrue(fastargs[4]);
+ if (line_buffering < 0) {
goto exit;
}
if (!--noptargs) {
goto skip_optional_pos;
}
}
- write_through = _PyLong_AsInt(fastargs[5]);
- if (write_through == -1 && PyErr_Occurred()) {
+ write_through = PyObject_IsTrue(fastargs[5]);
+ if (write_through < 0) {
goto exit;
}
skip_optional_pos:
@@ -769,4 +769,4 @@ _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored))
{
return _io_TextIOWrapper_close_impl(self);
}
-/*[clinic end generated code: output=aecd376eca3cb148 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=73f84b13c343b34b input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/winconsoleio.c.h b/Modules/_io/clinic/winconsoleio.c.h
index 65820a8..df834db 100644
--- a/Modules/_io/clinic/winconsoleio.c.h
+++ b/Modules/_io/clinic/winconsoleio.c.h
@@ -115,8 +115,8 @@ _io__WindowsConsoleIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
}
}
if (fastargs[2]) {
- closefd = _PyLong_AsInt(fastargs[2]);
- if (closefd == -1 && PyErr_Occurred()) {
+ closefd = PyObject_IsTrue(fastargs[2]);
+ if (closefd < 0) {
goto exit;
}
if (!--noptargs) {
@@ -407,4 +407,4 @@ _io__WindowsConsoleIO_isatty(winconsoleio *self, PyObject *Py_UNUSED(ignored))
#ifndef _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
#define _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
#endif /* !defined(_IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF) */
-/*[clinic end generated code: output=08ae244e9a44da55 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=4920e9068e0cf08a input=a9049054013a1b77]*/