bpo-35582: Argument Clinic: inline parsing code for positional parameters. (GH-11313)

diff --git a/Python/clinic/bltinmodule.c.h b/Python/clinic/bltinmodule.c.h
index 7f043da..68d8dcc 100644
--- a/Python/clinic/bltinmodule.c.h
+++ b/Python/clinic/bltinmodule.c.h
@@ -94,10 +94,22 @@
     PyObject *value;
     PyObject *format_spec = NULL;
 
-    if (!_PyArg_ParseStack(args, nargs, "O|U:format",
-        &value, &format_spec)) {
+    if (!_PyArg_CheckPositional("format", nargs, 1, 2)) {
         goto exit;
     }
+    value = args[0];
+    if (nargs < 2) {
+        goto skip_optional;
+    }
+    if (!PyUnicode_Check(args[1])) {
+        _PyArg_BadArgument("format", 2, "str", args[1]);
+        goto exit;
+    }
+    if (PyUnicode_READY(args[1]) == -1) {
+        goto exit;
+    }
+    format_spec = args[1];
+skip_optional:
     return_value = builtin_format_impl(module, value, format_spec);
 
 exit:
@@ -717,4 +729,4 @@
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=ed300ebf3f6db530 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=11b5cd918bd7eb18 input=a9049054013a1b77]*/
diff --git a/Python/clinic/import.c.h b/Python/clinic/import.c.h
index d34d68f..783ed4e 100644
--- a/Python/clinic/import.c.h
+++ b/Python/clinic/import.c.h
@@ -88,10 +88,22 @@
     PyCodeObject *code;
     PyObject *path;
 
-    if (!_PyArg_ParseStack(args, nargs, "O!U:_fix_co_filename",
-        &PyCode_Type, &code, &path)) {
+    if (!_PyArg_CheckPositional("_fix_co_filename", nargs, 2, 2)) {
         goto exit;
     }
+    if (!PyObject_TypeCheck(args[0], &PyCode_Type)) {
+        _PyArg_BadArgument("_fix_co_filename", 1, (&PyCode_Type)->tp_name, args[0]);
+        goto exit;
+    }
+    code = (PyCodeObject *)args[0];
+    if (!PyUnicode_Check(args[1])) {
+        _PyArg_BadArgument("_fix_co_filename", 2, "str", args[1]);
+        goto exit;
+    }
+    if (PyUnicode_READY(args[1]) == -1) {
+        goto exit;
+    }
+    path = args[1];
     return_value = _imp__fix_co_filename_impl(module, code, path);
 
 exit:
@@ -144,7 +156,7 @@
     PyObject *name;
 
     if (!PyUnicode_Check(arg)) {
-        _PyArg_BadArgument("init_frozen", "str", arg);
+        _PyArg_BadArgument("init_frozen", 0, "str", arg);
         goto exit;
     }
     if (PyUnicode_READY(arg) == -1) {
@@ -176,7 +188,7 @@
     PyObject *name;
 
     if (!PyUnicode_Check(arg)) {
-        _PyArg_BadArgument("get_frozen_object", "str", arg);
+        _PyArg_BadArgument("get_frozen_object", 0, "str", arg);
         goto exit;
     }
     if (PyUnicode_READY(arg) == -1) {
@@ -208,7 +220,7 @@
     PyObject *name;
 
     if (!PyUnicode_Check(arg)) {
-        _PyArg_BadArgument("is_frozen_package", "str", arg);
+        _PyArg_BadArgument("is_frozen_package", 0, "str", arg);
         goto exit;
     }
     if (PyUnicode_READY(arg) == -1) {
@@ -240,7 +252,7 @@
     PyObject *name;
 
     if (!PyUnicode_Check(arg)) {
-        _PyArg_BadArgument("is_builtin", "str", arg);
+        _PyArg_BadArgument("is_builtin", 0, "str", arg);
         goto exit;
     }
     if (PyUnicode_READY(arg) == -1) {
@@ -272,7 +284,7 @@
     PyObject *name;
 
     if (!PyUnicode_Check(arg)) {
-        _PyArg_BadArgument("is_frozen", "str", arg);
+        _PyArg_BadArgument("is_frozen", 0, "str", arg);
         goto exit;
     }
     if (PyUnicode_READY(arg) == -1) {
@@ -421,4 +433,4 @@
 #ifndef _IMP_EXEC_DYNAMIC_METHODDEF
     #define _IMP_EXEC_DYNAMIC_METHODDEF
 #endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */
-/*[clinic end generated code: output=d8be58c9541122f1 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=22062cee6e8ba7f3 input=a9049054013a1b77]*/
diff --git a/Python/clinic/marshal.c.h b/Python/clinic/marshal.c.h
index 516a315..ab45753 100644
--- a/Python/clinic/marshal.c.h
+++ b/Python/clinic/marshal.c.h
@@ -34,10 +34,24 @@
     PyObject *file;
     int version = Py_MARSHAL_VERSION;
 
-    if (!_PyArg_ParseStack(args, nargs, "OO|i:dump",
-        &value, &file, &version)) {
+    if (!_PyArg_CheckPositional("dump", nargs, 2, 3)) {
         goto exit;
     }
+    value = args[0];
+    file = args[1];
+    if (nargs < 3) {
+        goto skip_optional;
+    }
+    if (PyFloat_Check(args[2])) {
+        PyErr_SetString(PyExc_TypeError,
+                        "integer argument expected, got float" );
+        goto exit;
+    }
+    version = _PyLong_AsInt(args[2]);
+    if (version == -1 && PyErr_Occurred()) {
+        goto exit;
+    }
+skip_optional:
     return_value = marshal_dump_impl(module, value, file, version);
 
 exit:
@@ -90,10 +104,23 @@
     PyObject *value;
     int version = Py_MARSHAL_VERSION;
 
-    if (!_PyArg_ParseStack(args, nargs, "O|i:dumps",
-        &value, &version)) {
+    if (!_PyArg_CheckPositional("dumps", nargs, 1, 2)) {
         goto exit;
     }
+    value = args[0];
+    if (nargs < 2) {
+        goto skip_optional;
+    }
+    if (PyFloat_Check(args[1])) {
+        PyErr_SetString(PyExc_TypeError,
+                        "integer argument expected, got float" );
+        goto exit;
+    }
+    version = _PyLong_AsInt(args[1]);
+    if (version == -1 && PyErr_Occurred()) {
+        goto exit;
+    }
+skip_optional:
     return_value = marshal_dumps_impl(module, value, version);
 
 exit:
@@ -125,7 +152,7 @@
         goto exit;
     }
     if (!PyBuffer_IsContiguous(&bytes, 'C')) {
-        _PyArg_BadArgument("loads", "contiguous buffer", arg);
+        _PyArg_BadArgument("loads", 0, "contiguous buffer", arg);
         goto exit;
     }
     return_value = marshal_loads_impl(module, &bytes);
@@ -138,4 +165,4 @@
 
     return return_value;
 }
-/*[clinic end generated code: output=8262e7e6c8cbc1ef input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ae2bca1aa239e095 input=a9049054013a1b77]*/
diff --git a/Python/clinic/sysmodule.c.h b/Python/clinic/sysmodule.c.h
index 2d9c6e2..7370ab5 100644
--- a/Python/clinic/sysmodule.c.h
+++ b/Python/clinic/sysmodule.c.h
@@ -175,7 +175,7 @@
     PyObject *s;
 
     if (!PyUnicode_Check(arg)) {
-        _PyArg_BadArgument("intern", "str", arg);
+        _PyArg_BadArgument("intern", 0, "str", arg);
         goto exit;
     }
     if (PyUnicode_READY(arg) == -1) {
@@ -819,10 +819,22 @@
     PyObject *return_value = NULL;
     int depth = 0;
 
-    if (!_PyArg_ParseStack(args, nargs, "|i:_getframe",
-        &depth)) {
+    if (!_PyArg_CheckPositional("_getframe", nargs, 0, 1)) {
         goto exit;
     }
+    if (nargs < 1) {
+        goto skip_optional;
+    }
+    if (PyFloat_Check(args[0])) {
+        PyErr_SetString(PyExc_TypeError,
+                        "integer argument expected, got float" );
+        goto exit;
+    }
+    depth = _PyLong_AsInt(args[0]);
+    if (depth == -1 && PyErr_Occurred()) {
+        goto exit;
+    }
+skip_optional:
     return_value = sys__getframe_impl(module, depth);
 
 exit:
@@ -872,10 +884,15 @@
     PyObject *func;
     PyObject *funcargs;
 
-    if (!_PyArg_ParseStack(args, nargs, "OO!:call_tracing",
-        &func, &PyTuple_Type, &funcargs)) {
+    if (!_PyArg_CheckPositional("call_tracing", nargs, 2, 2)) {
         goto exit;
     }
+    func = args[0];
+    if (!PyTuple_Check(args[1])) {
+        _PyArg_BadArgument("call_tracing", 2, "tuple", args[1]);
+        goto exit;
+    }
+    funcargs = args[1];
     return_value = sys_call_tracing_impl(module, func, funcargs);
 
 exit:
@@ -1029,4 +1046,4 @@
 #ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
     #define SYS_GETANDROIDAPILEVEL_METHODDEF
 #endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */
-/*[clinic end generated code: output=0e662f2e19293d57 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=6a5202e5bfe5e6bd input=a9049054013a1b77]*/