Message209396
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. |
|
Date |
User |
Action |
Args |
2014-01-27 05:01:16 | ncoghlan | set | recipients:
+ ncoghlan, vstinner, larry, serhiy.storchaka |
2014-01-27 05:01:16 | ncoghlan | set | messageid: <1390798876.83.0.936873438895.issue20404@psf.upfronthosting.co.za> |
2014-01-27 05:01:16 | ncoghlan | link | issue20404 messages |
2014-01-27 05:01:16 | ncoghlan | create | |
|