Issue #26312: SystemError is now raised in all programming bugs with using
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 11 Feb 2016 10:41:40 +0000 (12:41 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Thu, 11 Feb 2016 10:41:40 +0000 (12:41 +0200)
PyArg_ParseTupleAndKeywords().  RuntimeError did raised before in some
programming bugs.

Lib/test/test_capi.py
Misc/NEWS
Python/getargs.c

index 1a743fdf2e6d6e289c98d52ff8bb86060dca6555..74ec6c51558f137a7466233ecfbc3187cb179a1c 100644 (file)
@@ -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)
 
index 22a392ef69b49871b73146e7318aeff577420d45..82b49d2cc45217722ed432e81072b9710f5574e7 100644 (file)
--- 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.
index be6e375edd87fb1262c80787697bde885383e0c6..66a0c0049b63f281d3c6e5522ba6d84780bbe13a 100644 (file)
@@ -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);