mirror of
https://github.com/python/cpython.git
synced 2025-08-27 04:05:34 +00:00
bpo-31243: Fixed PyArg_ParseTuple failure checks. (#3171)
This commit is contained in:
parent
e9d978fd1b
commit
ba7d736521
4 changed files with 65 additions and 21 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue