8000 bpo-31271: fix an assertion failure in io.TextIOWrapper.write by orenmn · Pull Request #3201 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-31271: fix an assertion failure in io.TextIOWrapper.write #3201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 25, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
simplify the test
  • Loading branch information
orenmn committed Aug 25, 2017
commit b4ccaa6b586ca4619f3d13211a1e40cd40ba4971
12 changes: 3 additions & 9 deletions Lib/test/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -3228,15 +3228,9 @@ def test_read_nonbytes(self):
def test_illegal_encoder(self):
# Issue 31271: Calling write() while the return value of encoder's
# encode() is invalid shouldn't cause an assertion failure.
class BadEncoder():
def encode(self, dummy):
return 42
def _get_bad_encoder(dummy):
return BadEncoder()
quopri = codecs.lookup("quopri")
with support.swap_attr(quopri, '_is_text_encoding', True), \
support.swap_attr(quopri, 'incrementalencoder', _get_bad_encoder):
t = io.TextIOWrapper(io.BytesIO(b'foo'), encoding="quopri")
rot13 = codecs.lookup("rot13")
with support.swap_attr(rot13, '_is_text_encoding', True):
t = io.TextIOWrapper(io.BytesIO(b'foo'), encoding="rot13")
self.assertRaises(TypeError, t.write, 'bar')

def test_illegal_decoder(self):
Expand Down
0