diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2024-02-05 20:51:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-05 20:51:11 (GMT) |
commit | 652fbf88c4c422ff17fefd4dcb5e06b5c0e26e74 (patch) | |
tree | 61b36dd4f458619c68bbee592bade7ed18993dda /Modules/faulthandler.c | |
parent | 09096a1647913526a3d4fa69a9d2056ec82a8f37 (diff) | |
download | cpython-652fbf88c4c422ff17fefd4dcb5e06b5c0e26e74.zip cpython-652fbf88c4c422ff17fefd4dcb5e06b5c0e26e74.tar.gz cpython-652fbf88c4c422ff17fefd4dcb5e06b5c0e26e74.tar.bz2 |
gh-82626: Emit a warning when bool is used as a file descriptor (GH-111275)
Diffstat (limited to 'Modules/faulthandler.c')
-rw-r--r-- | Modules/faulthandler.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c index a2e3c23..95d646c 100644 --- a/Modules/faulthandler.c +++ b/Modules/faulthandler.c @@ -119,6 +119,13 @@ faulthandler_get_fileno(PyObject **file_ptr) } } else if (PyLong_Check(file)) { + if (PyBool_Check(file)) { + if (PyErr_WarnEx(PyExc_RuntimeWarning, + "bool is used as a file descriptor", 1)) + { + return -1; + } + } fd = PyLong_AsInt(file); if (fd == -1 && PyErr_Occurred()) return -1; |