New submission from Nick Coghlan:
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.
----------
assignee: ncoghlan
messages: 209396
nosy: haypo, larry, ncoghlan, serhiy.storchaka
priority: release blocker
severity: normal
stage: test needed
status: open
title: Delayed exception using non-text encodings with TextIOWrapper
type: behavior
versions: Python 3.4
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue20404>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com