bpo-40943: Fix skipitem() didn't raise SystemError (GH-25937)
`convertitem()` raises `SystemError` when 'GH-' is used without `PY_SSIZE_T_CLEAN`.
This commit makes `skipitem()` raise it too.
(cherry picked from commit 4ebf4a6bfad4afcbab3baf9c0159c7767e2a64c0)
Co-authored-by: Inada Naoki <songofacandy@gmail.com>
diff --git a/Lib/test/test_getargs2.py b/Lib/test/test_getargs2.py
index c67e6f5..e0db9e4 100644
--- a/Lib/test/test_getargs2.py
+++ b/Lib/test/test_getargs2.py
@@ -874,6 +874,13 @@ def test_s_hash(self):
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')