diff options
author | Oren Milman <orenmn@gmail.com> | 2017-08-29 16:16:12 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-08-29 16:16:12 (GMT) |
commit | 20958e6d91d11a80d6c664ce6346791259b1d193 (patch) | |
tree | d6701eaaf00fd959e2833ac0443de54652135c1a /Lib/test/test_io.py | |
parent | 0b69b3723d018b197b94b173c3305bdef4c6b11b (diff) | |
download | cpython-20958e6d91d11a80d6c664ce6346791259b1d193.zip cpython-20958e6d91d11a80d6c664ce6346791259b1d193.tar.gz cpython-20958e6d91d11a80d6c664ce6346791259b1d193.tar.bz2 |
[2.7] bpo-31243: Fixed PyArg_ParseTuple failure checks. (GH-3171) (#3235)
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r-- | Lib/test/test_io.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index caca033..3dc6e9f 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -2702,6 +2702,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_codec") + with support.swap_attr(quopri, 'incrementaldecoder', + _get_bad_decoder): + return _make_illegal_wrapper() + t = _make_very_illegal_wrapper(42) + with self.maybeRaises(TypeError): + t.read(42) + t = _make_very_illegal_wrapper(()) + with self.maybeRaises(TypeError): + t.read(42) + class CTextIOWrapperTest(TextIOWrapperTest): |