You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
_colorize.can_colorize() raises when sys.stdout is mod_wsgi logger #141570
I don't know if raising OSError from .fileno() in mod_wsgi is OK or not, yet perhaps _colorize.can_colorize() should be more robust and expect either OSError or outright Exception. WDYT?
FWIW I won't do it right away, because I am thinking how to properly test this. Perhaps by calling _colorize.can_colorize(file=...) on a custom file-like object.
Activity
hroncok commentedon Nov 14, 2025
FWIW the docuemntation of fileno says:
That makes me think that expecting
io.UnsupportedOperationis outright wrong.hugovk commentedon Nov 14, 2025
Yes,
OSErrordoes make more sense here, would you like to open a PR?hroncok commentedon Nov 14, 2025
Will do.
hroncok commentedon Nov 14, 2025
FWIW I won't do it right away, because I am thinking how to properly test this. Perhaps by calling
_colorize.can_colorize(file=...)on a custom file-like object.can_colorize: Expect fileno() to raise OSError, as documented
cmaloney commentedon Nov 18, 2025
re:
OSError,io.UnsupportedOperationactually inherits from it so both should work. 👍 on changing to the more generic OSError check.gh-141570: can_colorize: Expect fileno() to raise OSError, as documen…
pythongh-141570: can_colorize: Expect fileno() to raise OSError, as d…
pythongh-141570: can_colorize: Expect fileno() to raise OSError, as d…
[3.13] gh-141570: can_colorize: Expect fileno() to raise OSError, as …
[3.14] gh-141570: can_colorize: Expect fileno() to raise OSError, as …
pythongh-141570: can_colorize: Expect fileno() to raise OSError, as d…
pythongh-141570: can_colorize: Expect fileno() to raise OSError, as d…