mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-141570: can_colorize: Expect fileno() to raise OSError, as documented (#141716) In Fedora, we've been given a slightly incomplete reproducer for a problematic Python 3.14 color-related change in argparse that leads to an exception when Python is used from mod_wsgi: https://bugzilla.redhat.com/2414940 mod_wsgi replaces sys.stdout with a custom object that raises OSError on .fileno():8460dbfcd5/src/server/wsgi_logger.c (L434-L440)This should be supported, as the documentation of fileno explicitly says: > An OSError is raised if the IO object does not use a file descriptor. https://docs.python.org/3.14/library/io.html#io.IOBase.fileno The previously expected exception inherits from OSError, so it is still expected. Fixes https://github.com/python/cpython/issues/141570 (cherry picked from commit96f496a949) Co-authored-by: Miro Hrončok <miro@hroncok.cz> Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
This commit is contained in:
parent
c7064e7d6b
commit
a0cbdd84af
3 changed files with 14 additions and 2 deletions
|
|
@ -1,5 +1,4 @@
|
|||
from __future__ import annotations
|
||||
import io
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
|
@ -116,5 +115,5 @@ def _safe_getenv(k: str, fallback: str | None = None) -> str | None:
|
|||
|
||||
try:
|
||||
return os.isatty(file.fileno())
|
||||
except io.UnsupportedOperation:
|
||||
except OSError:
|
||||
return hasattr(file, "isatty") and file.isatty()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue