gh-82626: Emit a warning when bool is used as a file descriptor (GH-111275)

This commit is contained in:
Serhiy Storchaka 2024-02-05 22:51:11 +02:00 committed by GitHub
parent 09096a1647
commit 652fbf88c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 75 additions and 0 deletions

View file

@ -969,6 +969,13 @@ _fd_converter(PyObject *o, int *p)
int overflow;
long long_value;
if (PyBool_Check(o)) {
if (PyErr_WarnEx(PyExc_RuntimeWarning,
"bool is used as a file descriptor", 1))
{
return 0;
}
}
PyObject *index = _PyNumber_Index(o);
if (index == NULL) {
return 0;