summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorOren Milman <orenmn@gmail.com>2017-08-25 18:14:54 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-08-25 18:14:54 (GMT)
commita5b4ea15b61e3f3985f4f0748a18f8b888a63532 (patch)
tree1fe8d1d522298d73105b17b9129e2a7c52ea2e00 /Lib
parentdce6502059f46a04f90938b9d832394c8215397b (diff)
downloadcpython-a5b4ea15b61e3f3985f4f0748a18f8b888a63532.zip
cpython-a5b4ea15b61e3f3985f4f0748a18f8b888a63532.tar.gz
cpython-a5b4ea15b61e3f3985f4f0748a18f8b888a63532.tar.bz2
bpo-31271: Fix an assertion failure in io.TextIOWrapper.write. (#3201)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_io.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index ab0cbe1..ba95c14 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -3225,6 +3225,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