bpo-40943: Fix skipitem() didn't raise SystemError (GH-25937)

`convertitem()` raises `SystemError` when '#' is used without `PY_SSIZE_T_CLEAN`.
This commit makes `skipitem()` raise it too.
This commit is contained in:
Inada Naoki 2021-05-07 11:56:48 +09:00 committed by GitHub
parent ee8e7c2fa9
commit 4ebf4a6bfa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 11 deletions

View file

@ -874,6 +874,13 @@ class String_TestCase(unittest.TestCase):
self.assertRaises(TypeError, getargs_s_hash, memoryview(b'memoryview'))
self.assertRaises(TypeError, getargs_s_hash, None)
def test_s_hash_int(self):
# "s#" without PY_SSIZE_T_CLEAN defined.
from _testcapi import getargs_s_hash_int
self.assertRaises(SystemError, getargs_s_hash_int, "abc")
self.assertRaises(SystemError, getargs_s_hash_int, x=42)
# getargs_s_hash_int() don't raise SystemError because skipitem() is not called.
def test_z(self):
from _testcapi import getargs_z
self.assertEqual(getargs_z('abc\xe9'), b'abc\xc3\xa9')