summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorOren Milman <orenmn@gmail.com>2017-08-29 12:43:32 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-08-29 12:43:32 (GMT)
commitc7750c2a3af014a5b742d0159d8957ea95b6c221 (patch)
tree164a30ef28a8ca03a797705c79659168db2211ef /Lib/test
parent83e5c888fff2bf3663952b2bfd3a3ee6c20386ef (diff)
downloadcpython-c7750c2a3af014a5b742d0159d8957ea95b6c221.zip
cpython-c7750c2a3af014a5b742d0159d8957ea95b6c221.tar.gz
cpython-c7750c2a3af014a5b742d0159d8957ea95b6c221.tar.bz2
[3.6] bpo-31243: Fixed PyArg_ParseTuple failure checks. (GH-3171) (#3233)
(cherry picked from commit ba7d7365215d791025d1efd25393c91404f2cfc8)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_io.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 7057c92..08c041e 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -3191,6 +3191,26 @@ class TextIOWrapperTest(unittest.TestCase):
t = _make_illegal_wrapper()
self.assertRaises(TypeError, t.read)
+ # Issue 31243: calling read() while the return value of decoder's
+ # getstate() is invalid should neither crash the interpreter nor
+ # raise a SystemError.
+ def _make_very_illegal_wrapper(getstate_ret_val):
+ class BadDecoder:
+ def getstate(self):
+ return getstate_ret_val
+ def _get_bad_decoder(dummy):
+ return BadDecoder()
+ quopri = codecs.lookup("quopri")
+ with support.swap_attr(quopri, 'incrementaldecoder',
+ _get_bad_decoder):
+ return _make_illegal_wrapper()
+ t = _make_very_illegal_wrapper(42)
+ self.assertRaises(TypeError, t.read, 42)
+ t = _make_very_illegal_wrapper(())
+ self.assertRaises(TypeError, t.read, 42)
+ t = _make_very_illegal_wrapper((1, 2))
+ self.assertRaises(TypeError, t.read, 42)
+
def _check_create_at_shutdown(self, **kwargs):
# Issue #20037: creating a TextIOWrapper at shutdown
# shouldn't crash the interpreter.