mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
gh-115538: Emit warning when use bool as fd in _io.WindowsConsoleIO (GH-116925)
This commit is contained in:
parent
43c9d6196a
commit
cd2ed91780
3 changed files with 15 additions and 0 deletions
|
|
@ -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()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue