diff options
author | Jesus Cea <jcea@jcea.es> | 2012-10-04 14:07:03 (GMT) |
---|---|---|
committer | Jesus Cea <jcea@jcea.es> | 2012-10-04 14:07:03 (GMT) |
commit | d96c1fb6edc3db885c85ec608aa7d3c2415163a9 (patch) | |
tree | 6a6ccda8e69c7a4f8542a0b078b4f44abd49a72d | |
parent | 677ffd16bf8ec440a22b65042293654c6a76095f (diff) | |
parent | 6e1d2b6e7889a138c02c027f8c3dce6ead62e3cf (diff) | |
download | cpython-d96c1fb6edc3db885c85ec608aa7d3c2415163a9.zip cpython-d96c1fb6edc3db885c85ec608aa7d3c2415163a9.tar.gz cpython-d96c1fb6edc3db885c85ec608aa7d3c2415163a9.tar.bz2 |
MERGE: Closes #16126: PyErr_Format format mismatch in _testcapimodule.c
-rw-r--r-- | Lib/test/test_capi.py | 11 | ||||
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Modules/_testcapimodule.c | 2 |
3 files changed, 15 insertions, 1 deletions
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py index d3c4a04..af15a3d 100644 --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -316,6 +316,17 @@ class SkipitemTest(unittest.TestCase): c, i, when_skipped, when_not_skipped)) 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(): support.run_unittest(CAPITest, TestPendingCalls, Test6012, EmbeddingTest, SkipitemTest) @@ -83,6 +83,9 @@ Library `io.BytesIO` and `io.StringIO` objects now raise ValueError when the object 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 `os.devnull` explicitly and leaving it open. diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index ce58651..ab11f51 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -1238,7 +1238,7 @@ parse_tuple_and_keywords(PyObject *self, PyObject *args) o = PySequence_Fast_GET_ITEM(sub_keywords, i); if (!PyUnicode_FSConverter(o, (void *)(converted + i))) { 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; } keywords[i] = PyBytes_AS_STRING(converted[i]); |