summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorOren Milman <orenmn@gmail.com>2017-08-26 17:29:40 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-08-26 17:29:40 (GMT)
commit9bcbc6cba385a83cac8f1ff430cad7617184d2bc (patch)
tree93788d8c91a855ce70ac39d466cd2dc9e8633918 /Lib/test
parent8e67981fc8e1bf3cb9774b5fbf4a39b8d65ba4ff (diff)
downloadcpython-9bcbc6cba385a83cac8f1ff430cad7617184d2bc.zip
cpython-9bcbc6cba385a83cac8f1ff430cad7617184d2bc.tar.gz
cpython-9bcbc6cba385a83cac8f1ff430cad7617184d2bc.tar.bz2
[3.6] bpo-31271: Fix an assertion failure in io.TextIOWrapper.write. (GH-3201) (#3209)
(cherry picked from commit a5b4ea15b61e3f3985f4f0748a18f8b888a63532)
Diffstat (limited to 'Lib/test')
-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 6a2c7a9f..7057c92 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -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