mirror of
https://github.com/python/cpython.git
synced 2025-10-06 23:21:06 +00:00
[3.6] bpo-31271: Fix an assertion failure in io.TextIOWrapper.write. (GH-3201) (#3209)
(cherry picked from commit a5b4ea15b6
)
This commit is contained in:
parent
8e67981fc8
commit
9bcbc6cba3
3 changed files with 17 additions and 0 deletions
|
@ -3163,6 +3163,14 @@ class TextIOWrapperTest(unittest.TestCase):
|
|||
t = self.TextIOWrapper(self.StringIO('a'))
|
||||
self.assertRaises(TypeError, t.read)
|
||||
|
||||
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.
|
||||
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):
|
||||
# Issue #17106
|
||||
# Bypass the early encoding check added in issue 20404
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue