mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
Issue #26312: SystemError is now raised in all programming bugs with using
PyArg_ParseTupleAndKeywords(). RuntimeError did raised before in some programming bugs.
This commit is contained in:
parent
78f55ffc63
commit
a9725f86a9
3 changed files with 12 additions and 8 deletions
|
@ -491,7 +491,7 @@ class SkipitemTest(unittest.TestCase):
|
||||||
except SystemError as e:
|
except SystemError as e:
|
||||||
s = "argument 1 (impossible<bad format char>)"
|
s = "argument 1 (impossible<bad format char>)"
|
||||||
when_not_skipped = (str(e) == s)
|
when_not_skipped = (str(e) == s)
|
||||||
except (TypeError, RuntimeError):
|
except TypeError:
|
||||||
when_not_skipped = False
|
when_not_skipped = False
|
||||||
|
|
||||||
# test the format unit when skipped
|
# test the format unit when skipped
|
||||||
|
@ -500,7 +500,7 @@ class SkipitemTest(unittest.TestCase):
|
||||||
_testcapi.parse_tuple_and_keywords(empty_tuple, dict_b,
|
_testcapi.parse_tuple_and_keywords(empty_tuple, dict_b,
|
||||||
optional_format.encode("ascii"), keywords)
|
optional_format.encode("ascii"), keywords)
|
||||||
when_skipped = False
|
when_skipped = False
|
||||||
except RuntimeError as e:
|
except SystemError as e:
|
||||||
s = "impossible<bad format char>: '{}'".format(format)
|
s = "impossible<bad format char>: '{}'".format(format)
|
||||||
when_skipped = (str(e) == s)
|
when_skipped = (str(e) == s)
|
||||||
|
|
||||||
|
|
|
@ -741,6 +741,10 @@ Tools/Demos
|
||||||
C API
|
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
|
- Issue #26198: ValueError is now raised instead of TypeError on buffer
|
||||||
overflow in parsing "es#" and "et#" format units. SystemError is now raised
|
overflow in parsing "es#" and "et#" format units. SystemError is now raised
|
||||||
instead of TypeError on programmical error in parsing format string.
|
instead of TypeError on programmical error in parsing format string.
|
||||||
|
|
|
@ -1512,7 +1512,7 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
|
||||||
keyword = kwlist[i];
|
keyword = kwlist[i];
|
||||||
if (*format == '|') {
|
if (*format == '|') {
|
||||||
if (min != INT_MAX) {
|
if (min != INT_MAX) {
|
||||||
PyErr_SetString(PyExc_RuntimeError,
|
PyErr_SetString(PyExc_SystemError,
|
||||||
"Invalid format string (| specified twice)");
|
"Invalid format string (| specified twice)");
|
||||||
return cleanreturn(0, &freelist);
|
return cleanreturn(0, &freelist);
|
||||||
}
|
}
|
||||||
|
@ -1521,14 +1521,14 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
|
||||||
format++;
|
format++;
|
||||||
|
|
||||||
if (max != INT_MAX) {
|
if (max != INT_MAX) {
|
||||||
PyErr_SetString(PyExc_RuntimeError,
|
PyErr_SetString(PyExc_SystemError,
|
||||||
"Invalid format string ($ before |)");
|
"Invalid format string ($ before |)");
|
||||||
return cleanreturn(0, &freelist);
|
return cleanreturn(0, &freelist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*format == '$') {
|
if (*format == '$') {
|
||||||
if (max != INT_MAX) {
|
if (max != INT_MAX) {
|
||||||
PyErr_SetString(PyExc_RuntimeError,
|
PyErr_SetString(PyExc_SystemError,
|
||||||
"Invalid format string ($ specified twice)");
|
"Invalid format string ($ specified twice)");
|
||||||
return cleanreturn(0, &freelist);
|
return cleanreturn(0, &freelist);
|
||||||
}
|
}
|
||||||
|
@ -1546,7 +1546,7 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (IS_END_OF_FORMAT(*format)) {
|
if (IS_END_OF_FORMAT(*format)) {
|
||||||
PyErr_Format(PyExc_RuntimeError,
|
PyErr_Format(PyExc_SystemError,
|
||||||
"More keyword list entries (%d) than "
|
"More keyword list entries (%d) than "
|
||||||
"format specifiers (%d)", len, i);
|
"format specifiers (%d)", len, i);
|
||||||
return cleanreturn(0, &freelist);
|
return cleanreturn(0, &freelist);
|
||||||
|
@ -1598,14 +1598,14 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
|
||||||
* keyword args */
|
* keyword args */
|
||||||
msg = skipitem(&format, p_va, flags);
|
msg = skipitem(&format, p_va, flags);
|
||||||
if (msg) {
|
if (msg) {
|
||||||
PyErr_Format(PyExc_RuntimeError, "%s: '%s'", msg,
|
PyErr_Format(PyExc_SystemError, "%s: '%s'", msg,
|
||||||
format);
|
format);
|
||||||
return cleanreturn(0, &freelist);
|
return cleanreturn(0, &freelist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IS_END_OF_FORMAT(*format) && (*format != '|') && (*format != '$')) {
|
if (!IS_END_OF_FORMAT(*format) && (*format != '|') && (*format != '$')) {
|
||||||
PyErr_Format(PyExc_RuntimeError,
|
PyErr_Format(PyExc_SystemError,
|
||||||
"more argument specifiers than keyword list entries "
|
"more argument specifiers than keyword list entries "
|
||||||
"(remaining format:'%s')", format);
|
"(remaining format:'%s')", format);
|
||||||
return cleanreturn(0, &freelist);
|
return cleanreturn(0, &freelist);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue