# HG changeset patch # User Jesus Cea # Date 1349359623 -7200 # Node ID 366c19bb5ca28f75d682b285b9e539a2aa549d3a # Parent cd026866b333d3f6b23b015b48719af03a5ec27b# Parent 0fc259ac8733da5a23372b542e4206e12f15f05c MERGE: Closes #16126: PyErr_Format format mismatch in _testcapimodule.c diff -r cd026866b333 -r 366c19bb5ca2 Lib/test/test_capi.py --- a/Lib/test/test_capi.py Thu Oct 04 13:58:22 2012 +0200 +++ b/Lib/test/test_capi.py Thu Oct 04 16:07:03 2012 +0200 @@ -316,6 +316,17 @@ 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) diff -r cd026866b333 -r 366c19bb5ca2 Misc/NEWS --- a/Misc/NEWS Thu Oct 04 13:58:22 2012 +0200 +++ b/Misc/NEWS Thu Oct 04 16:07:03 2012 +0200 @@ -83,6 +83,9 @@ `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 -r cd026866b333 -r 366c19bb5ca2 Modules/_testcapimodule.c --- a/Modules/_testcapimodule.c Thu Oct 04 13:58:22 2012 +0200 +++ b/Modules/_testcapimodule.c Thu Oct 04 16:07:03 2012 +0200 @@ -1238,7 +1238,7 @@ 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]);