mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Issue #26198: ValueError is now raised instead of TypeError on buffer
overflow in parsing "es#" and "et#" format units. SystemError is now raised instead of TypeError on programmical error in parsing format string.
This commit is contained in:
parent
3e17c788a8
commit
4cd63ef67a
4 changed files with 20 additions and 8 deletions
|
@ -636,10 +636,10 @@ class String_TestCase(unittest.TestCase):
|
|||
self.assertEqual(getargs_es_hash('abc\xe9', 'latin1', buf), b'abc\xe9')
|
||||
self.assertEqual(buf, bytearray(b'abc\xe9\x00'))
|
||||
buf = bytearray(b'x'*4)
|
||||
self.assertRaises(TypeError, getargs_es_hash, 'abc\xe9', 'latin1', buf)
|
||||
self.assertRaises(ValueError, getargs_es_hash, 'abc\xe9', 'latin1', buf)
|
||||
self.assertEqual(buf, bytearray(b'x'*4))
|
||||
buf = bytearray()
|
||||
self.assertRaises(TypeError, getargs_es_hash, 'abc\xe9', 'latin1', buf)
|
||||
self.assertRaises(ValueError, getargs_es_hash, 'abc\xe9', 'latin1', buf)
|
||||
|
||||
def test_et_hash(self):
|
||||
from _testcapi import getargs_et_hash
|
||||
|
@ -662,10 +662,10 @@ class String_TestCase(unittest.TestCase):
|
|||
self.assertEqual(getargs_et_hash('abc\xe9', 'latin1', buf), b'abc\xe9')
|
||||
self.assertEqual(buf, bytearray(b'abc\xe9\x00'))
|
||||
buf = bytearray(b'x'*4)
|
||||
self.assertRaises(TypeError, getargs_et_hash, 'abc\xe9', 'latin1', buf)
|
||||
self.assertRaises(ValueError, getargs_et_hash, 'abc\xe9', 'latin1', buf)
|
||||
self.assertEqual(buf, bytearray(b'x'*4))
|
||||
buf = bytearray()
|
||||
self.assertRaises(TypeError, getargs_et_hash, 'abc\xe9', 'latin1', buf)
|
||||
self.assertRaises(ValueError, getargs_et_hash, 'abc\xe9', 'latin1', buf)
|
||||
|
||||
def test_u(self):
|
||||
from _testcapi import getargs_u
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue