Author erik.bray
Recipients aliles, amaury.forgeotdarc, belopolsky, dangyogi, erik.bray, flox, gruszczy, martin.panter, pitrou, r.david.murray, serhiy.storchaka, vstinner
Date 2015-11-23.20:17:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1448309866.77.0.884521598119.issue8256@psf.upfronthosting.co.za>
In-reply-to
Content
I just recently discovered this myself.  In the process of debugging the issue I also noticed the same bug that is now fixed via Issue 24402.

While I agree that Issue 24402 mostly mitigates the issue I think this patch is still worthwhile, as the current behavior still leads to cryptic, hard to debug errors.  For example (although this is not great code, bear with me...) one could write a stdout wrapper like:

>>> class WrappedStream:
...     encoding = 'utf8'
...     errors = None
...     def __getattr__(self, attr):
...         return getattr(sys.__stdout__, attr)
... 
>>> sys.stdout = WrappedStream()
>>> sys.stdout.fileno()
1
>>> sys.stdout.isatty()
True
>>> sys.stdout.errors
>>> input('Prompt: ')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: bad argument type for built-in operation

This still goes down the path for ttys, but because the 'errors' attribute does not defer to the underlying stream it still leads to a hard to debug exception.  To be clear, I think the above code *should* break, just not as cryptically.
History
Date User Action Args
2015-11-23 20:17:46erik.braysetrecipients: + erik.bray, amaury.forgeotdarc, belopolsky, pitrou, vstinner, dangyogi, r.david.murray, gruszczy, flox, aliles, martin.panter, serhiy.storchaka
2015-11-23 20:17:46erik.braysetmessageid: <1448309866.77.0.884521598119.issue8256@psf.upfronthosting.co.za>
2015-11-23 20:17:46erik.braylinkissue8256 messages
2015-11-23 20:17:46erik.braycreate