Commit 6e1d2b6e authored by Jesus Cea's avatar Jesus Cea

Closes #16126: PyErr_Format format mismatch in _testcapimodule.c

parent e8801e2e
...@@ -316,6 +316,17 @@ class SkipitemTest(unittest.TestCase): ...@@ -316,6 +316,17 @@ class SkipitemTest(unittest.TestCase):
c, i, when_skipped, when_not_skipped)) c, i, when_skipped, when_not_skipped))
self.assertIs(when_skipped, when_not_skipped, message) self.assertIs(when_skipped, when_not_skipped, message)
def test_parse_tuple_and_keywords(self):
# parse_tuple_and_keywords error handling tests
self.assertRaises(TypeError, _testcapi.parse_tuple_and_keywords,
(), {}, 42, [])
self.assertRaises(ValueError, _testcapi.parse_tuple_and_keywords,
(), {}, b'', 42)
self.assertRaises(ValueError, _testcapi.parse_tuple_and_keywords,
(), {}, b'', [''] * 42)
self.assertRaises(ValueError, _testcapi.parse_tuple_and_keywords,
(), {}, b'', [42])
def test_main(): def test_main():
support.run_unittest(CAPITest, TestPendingCalls, support.run_unittest(CAPITest, TestPendingCalls,
Test6012, EmbeddingTest, SkipitemTest) Test6012, EmbeddingTest, SkipitemTest)
......
...@@ -73,6 +73,9 @@ Library ...@@ -73,6 +73,9 @@ Library
`io.BytesIO` and `io.StringIO` objects now raise ValueError when the object `io.BytesIO` and `io.StringIO` objects now raise ValueError when the object
has been closed. Patch by Alessandro Moura. has been closed. Patch by Alessandro Moura.
- Issue #16126: PyErr_Format format mismatch in _testcapimodule.c.
Patch by Serhiy Storchaka.
- Issue #15447: Use `subprocess.DEVNULL` in webbrowser, instead of opening - Issue #15447: Use `subprocess.DEVNULL` in webbrowser, instead of opening
`os.devnull` explicitly and leaving it open. `os.devnull` explicitly and leaving it open.
......
...@@ -1238,7 +1238,7 @@ parse_tuple_and_keywords(PyObject *self, PyObject *args) ...@@ -1238,7 +1238,7 @@ parse_tuple_and_keywords(PyObject *self, PyObject *args)
o = PySequence_Fast_GET_ITEM(sub_keywords, i); o = PySequence_Fast_GET_ITEM(sub_keywords, i);
if (!PyUnicode_FSConverter(o, (void *)(converted + i))) { if (!PyUnicode_FSConverter(o, (void *)(converted + i))) {
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"parse_tuple_and_keywords: could not convert keywords[%s] to narrow string", i); "parse_tuple_and_keywords: could not convert keywords[%zd] to narrow string", i);
goto exit; goto exit;
} }
keywords[i] = PyBytes_AS_STRING(converted[i]); keywords[i] = PyBytes_AS_STRING(converted[i]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment