diff options
| author | Oren Milman <orenmn@gmail.com> | 2017-08-29 08:58:27 (GMT) | 
|---|---|---|
| committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-08-29 08:58:27 (GMT) | 
| commit | ba7d7365215d791025d1efd25393c91404f2cfc8 (patch) | |
| tree | 8ba0a3b1944172f450f0d76f588bb106dd50e174 /Lib/test/test_io.py | |
| parent | e9d978fd1bc122395efc91a82b16b2c4b968441d (diff) | |
| download | cpython-ba7d7365215d791025d1efd25393c91404f2cfc8.zip cpython-ba7d7365215d791025d1efd25393c91404f2cfc8.tar.gz cpython-ba7d7365215d791025d1efd25393c91404f2cfc8.tar.bz2  | |
bpo-31243: Fixed PyArg_ParseTuple failure checks. (#3171)
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 ba95c14..48270c8 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -3253,6 +3253,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.  | 
