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:
Serhiy Storchaka 2016-02-08 01:22:47 +02:00
parent 3e17c788a8
commit 4cd63ef67a
4 changed files with 20 additions and 8 deletions

View file

@ -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