This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients larry, ncoghlan, serhiy.storchaka, vstinner
Date 2014-01-27.05:01:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1390798876.83.0.936873438895.issue20404@psf.upfronthosting.co.za>
In-reply-to
Content
TextIOWrapper doesn't check the codec type early the way the convenience methods now do, so the open() method currently still suffers from the problems Victor described in issue 19619 for str.encode() and bytes.decode():

>>> with open("hex.txt", 'w') as f:
...     f.write("aabbccddeeff")
... 
12
>>> print(open('hex.txt').read())
aabbccddeeff
>>> print(open('hex.txt', encoding='hex').read())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: decoder should return a string result, not 'bytes'

These codecs are never going to work correctly with TextIOWrapper, so we should add the appropriate compatibility check in the constructor.
History
Date User Action Args
2014-01-27 05:01:16ncoghlansetrecipients: + ncoghlan, vstinner, larry, serhiy.storchaka
2014-01-27 05:01:16ncoghlansetmessageid: <1390798876.83.0.936873438895.issue20404@psf.upfronthosting.co.za>
2014-01-27 05:01:16ncoghlanlinkissue20404 messages
2014-01-27 05:01:16ncoghlancreate