]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-94512: Fix forced arg format in AC-processed msvcrtmodule (GH-94514)
authorOleg Iarygin <oleg@arhadthedev.net>
Mon, 4 Jul 2022 13:09:34 +0000 (16:09 +0300)
committerGitHub <noreply@github.com>
Mon, 4 Jul 2022 13:09:34 +0000 (14:09 +0100)
PC/clinic/msvcrtmodule.c.h
PC/msvcrtmodule.c

index ea95897590fe477374ab211a45ac94894196442c..e60fbd0b623cd4d3b173974fc8ae54bcb1967539 100644 (file)
@@ -141,8 +141,15 @@ msvcrt_open_osfhandle(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     int flags;
     long _return_value;
 
-    if (!_PyArg_ParseStack(args, nargs, ""_Py_PARSE_UINTPTR"i:open_osfhandle",
-        &handle, &flags)) {
+    if (!_PyArg_CheckPositional("open_osfhandle", nargs, 2, 2)) {
+        goto exit;
+    }
+    handle = PyLong_AsVoidPtr(args[0]);
+    if (!handle && PyErr_Occurred()) {
+        goto exit;
+    }
+    flags = _PyLong_AsInt(args[1]);
+    if (flags == -1 && PyErr_Occurred()) {
         goto exit;
     }
     _return_value = msvcrt_open_osfhandle_impl(module, handle, flags);
@@ -488,8 +495,15 @@ msvcrt_CrtSetReportFile(PyObject *module, PyObject *const *args, Py_ssize_t narg
     void *file;
     void *_return_value;
 
-    if (!_PyArg_ParseStack(args, nargs, "i"_Py_PARSE_UINTPTR":CrtSetReportFile",
-        &type, &file)) {
+    if (!_PyArg_CheckPositional("CrtSetReportFile", nargs, 2, 2)) {
+        goto exit;
+    }
+    type = _PyLong_AsInt(args[0]);
+    if (type == -1 && PyErr_Occurred()) {
+        goto exit;
+    }
+    file = PyLong_AsVoidPtr(args[1]);
+    if (!file && PyErr_Occurred()) {
         goto exit;
     }
     _return_value = msvcrt_CrtSetReportFile_impl(module, type, file);
@@ -647,4 +661,4 @@ exit:
 #ifndef MSVCRT_SET_ERROR_MODE_METHODDEF
     #define MSVCRT_SET_ERROR_MODE_METHODDEF
 #endif /* !defined(MSVCRT_SET_ERROR_MODE_METHODDEF) */
-/*[clinic end generated code: output=b543933cad520f2b input=a9049054013a1b77]*/
+/*[clinic end generated code: output=9d89e9414484d28c input=a9049054013a1b77]*/
index 1f78d99c790ff9cdb4e8757566081d4a1c288bb5..988d9c95aaa22ea816eea476d3fe546ac4006874 100644 (file)
@@ -38,6 +38,14 @@ class HANDLE_converter(CConverter):
     type = 'void *'
     format_unit = '"_Py_PARSE_UINTPTR"'
 
+    def parse_arg(self, argname, displayname):
+        return """
+            {paramname} = PyLong_AsVoidPtr({argname});
+            if (!{paramname} && PyErr_Occurred()) {{{{
+                goto exit;
+            }}}}
+            """.format(argname=argname, paramname=self.parser_name)
+
 class HANDLE_return_converter(CReturnConverter):
     type = 'void *'
 
@@ -66,7 +74,7 @@ class wchar_t_return_converter(CReturnConverter):
         data.return_conversion.append(
             'return_value = PyUnicode_FromOrdinal(_return_value);\n')
 [python start generated code]*/
-/*[python end generated code: output=da39a3ee5e6b4b0d input=d102511df3cda2eb]*/
+/*[python end generated code: output=da39a3ee5e6b4b0d input=1e8e9fa3538ec08f]*/
 
 /*[clinic input]
 module msvcrt