mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
gh-82626: Emit a warning when bool is used as a file descriptor (GH-111275)
This commit is contained in:
parent
09096a1647
commit
652fbf88c4
11 changed files with 75 additions and 0 deletions
|
|
@ -174,6 +174,13 @@ PyObject_AsFileDescriptor(PyObject *o)
|
|||
PyObject *meth;
|
||||
|
||||
if (PyLong_Check(o)) {
|
||||
if (PyBool_Check(o)) {
|
||||
if (PyErr_WarnEx(PyExc_RuntimeWarning,
|
||||
"bool is used as a file descriptor", 1))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
fd = PyLong_AsInt(o);
|
||||
}
|
||||
else if (PyObject_GetOptionalAttr(o, &_Py_ID(fileno), &meth) < 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue