summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorAN Long <aisk@users.noreply.github.com>2024-03-18 11:48:50 (GMT)
committerGitHub <noreply@github.com>2024-03-18 11:48:50 (GMT)
commitcd2ed917801b93fb46d1dcf19dd480e5146932d8 (patch)
treec60a9654a99633c5509a9981734bd75e29953381 /Modules
parent43c9d6196a8593ebd1fda221a277dccb984e84b6 (diff)
downloadcpython-cd2ed917801b93fb46d1dcf19dd480e5146932d8.zip
cpython-cd2ed917801b93fb46d1dcf19dd480e5146932d8.tar.gz
cpython-cd2ed917801b93fb46d1dcf19dd480e5146932d8.tar.bz2
gh-115538: Emit warning when use bool as fd in _io.WindowsConsoleIO (GH-116925)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_io/winconsoleio.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Modules/_io/winconsoleio.c b/Modules/_io/winconsoleio.c
index 54e1555..ec5c298 100644
--- a/Modules/_io/winconsoleio.c
+++ b/Modules/_io/winconsoleio.c
@@ -298,6 +298,13 @@ _io__WindowsConsoleIO___init___impl(winconsoleio *self, PyObject *nameobj,
self->fd = -1;
}
+ if (PyBool_Check(nameobj)) {
+ if (PyErr_WarnEx(PyExc_RuntimeWarning,
+ "bool is used as a file descriptor", 1))
+ {
+ return -1;
+ }
+ }
fd = PyLong_AsInt(nameobj);
if (fd < 0) {
if (!PyErr_Occurred()) {