summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-02-11 10:41:40 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-02-11 10:41:40 (GMT)
commita9725f86a984f74e74f09c4808fc8f4b403728b2 (patch)
tree99da32331ded11bdd6dee41990bee66226acfa2b
parent78f55ffc63ba637ffa4a07ca869f451e680b002a (diff)
downloadcpython-a9725f86a984f74e74f09c4808fc8f4b403728b2.zip
cpython-a9725f86a984f74e74f09c4808fc8f4b403728b2.tar.gz
cpython-a9725f86a984f74e74f09c4808fc8f4b403728b2.tar.bz2
Issue #26312: SystemError is now raised in all programming bugs with using
PyArg_ParseTupleAndKeywords(). RuntimeError did raised before in some programming bugs.
-rw-r--r--Lib/test/test_capi.py4
-rw-r--r--Misc/NEWS4
-rw-r--r--Python/getargs.c12
3 files changed, 12 insertions, 8 deletions
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py
index 1a743fd..74ec6c5 100644
--- a/Lib/test/test_capi.py
+++ b/Lib/test/test_capi.py
@@ -491,7 +491,7 @@ class SkipitemTest(unittest.TestCase):
except SystemError as e:
s = "argument 1 (impossible<bad format char>)"
when_not_skipped = (str(e) == s)
- except (TypeError, RuntimeError):
+ except TypeError:
when_not_skipped = False
# test the format unit when skipped
@@ -500,7 +500,7 @@ class SkipitemTest(unittest.TestCase):
_testcapi.parse_tuple_and_keywords(empty_tuple, dict_b,
optional_format.encode("ascii"), keywords)
when_skipped = False
- except RuntimeError as e:
+ except SystemError as e:
s = "impossible<bad format char>: '{}'".format(format)
when_skipped = (str(e) == s)
diff --git a/Misc/NEWS b/Misc/NEWS
index 22a392e..82b49d2 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -741,6 +741,10 @@ Tools/Demos
C API
-----
+- Issue #26312: SystemError is now raised in all programming bugs with using
+ PyArg_ParseTupleAndKeywords(). RuntimeError did raised before in some
+ programming bugs.
+
- Issue #26198: ValueError is now raised instead of TypeError on buffer
overflow in parsing "es#" and "et#" format units. SystemError is now raised
instead of TypeError on programmical error in parsing format string.
diff --git a/Python/getargs.c b/Python/getargs.c
index be6e375..66a0c00 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -1512,7 +1512,7 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
keyword = kwlist[i];
if (*format == '|') {
if (min != INT_MAX) {
- PyErr_SetString(PyExc_RuntimeError,
+ PyErr_SetString(PyExc_SystemError,
"Invalid format string (| specified twice)");
return cleanreturn(0, &freelist);
}
@@ -1521,14 +1521,14 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
format++;
if (max != INT_MAX) {
- PyErr_SetString(PyExc_RuntimeError,
+ PyErr_SetString(PyExc_SystemError,
"Invalid format string ($ before |)");
return cleanreturn(0, &freelist);
}
}
if (*format == '$') {
if (max != INT_MAX) {
- PyErr_SetString(PyExc_RuntimeError,
+ PyErr_SetString(PyExc_SystemError,
"Invalid format string ($ specified twice)");
return cleanreturn(0, &freelist);
}
@@ -1546,7 +1546,7 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
}
}
if (IS_END_OF_FORMAT(*format)) {
- PyErr_Format(PyExc_RuntimeError,
+ PyErr_Format(PyExc_SystemError,
"More keyword list entries (%d) than "
"format specifiers (%d)", len, i);
return cleanreturn(0, &freelist);
@@ -1598,14 +1598,14 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
* keyword args */
msg = skipitem(&format, p_va, flags);
if (msg) {
- PyErr_Format(PyExc_RuntimeError, "%s: '%s'", msg,
+ PyErr_Format(PyExc_SystemError, "%s: '%s'", msg,
format);
return cleanreturn(0, &freelist);
}
}
if (!IS_END_OF_FORMAT(*format) && (*format != '|') && (*format != '$')) {
- PyErr_Format(PyExc_RuntimeError,
+ PyErr_Format(PyExc_SystemError,
"more argument specifiers than keyword list entries "
"(remaining format:'%s')", format);
return cleanreturn(0, &freelist);