bpo-23867: Argument Clinic: inline parsing code for a single positional parameter. (GH-9689)
diff --git a/Modules/clinic/_tkinter.c.h b/Modules/clinic/_tkinter.c.h
index a09bc2d..1eedd2b 100644
--- a/Modules/clinic/_tkinter.c.h
+++ b/Modules/clinic/_tkinter.c.h
@@ -19,7 +19,17 @@
PyObject *return_value = NULL;
const char *script;
- if (!PyArg_Parse(arg, "s:eval", &script)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("eval", "str", arg);
+ goto exit;
+ }
+ Py_ssize_t script_length;
+ script = PyUnicode_AsUTF8AndSize(arg, &script_length);
+ if (script == NULL) {
+ goto exit;
+ }
+ if (strlen(script) != (size_t)script_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _tkinter_tkapp_eval_impl(self, script);
@@ -45,7 +55,17 @@
PyObject *return_value = NULL;
const char *fileName;
- if (!PyArg_Parse(arg, "s:evalfile", &fileName)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("evalfile", "str", arg);
+ goto exit;
+ }
+ Py_ssize_t fileName_length;
+ fileName = PyUnicode_AsUTF8AndSize(arg, &fileName_length);
+ if (fileName == NULL) {
+ goto exit;
+ }
+ if (strlen(fileName) != (size_t)fileName_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _tkinter_tkapp_evalfile_impl(self, fileName);
@@ -71,7 +91,17 @@
PyObject *return_value = NULL;
const char *script;
- if (!PyArg_Parse(arg, "s:record", &script)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("record", "str", arg);
+ goto exit;
+ }
+ Py_ssize_t script_length;
+ script = PyUnicode_AsUTF8AndSize(arg, &script_length);
+ if (script == NULL) {
+ goto exit;
+ }
+ if (strlen(script) != (size_t)script_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _tkinter_tkapp_record_impl(self, script);
@@ -97,7 +127,17 @@
PyObject *return_value = NULL;
const char *msg;
- if (!PyArg_Parse(arg, "s:adderrorinfo", &msg)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("adderrorinfo", "str", arg);
+ goto exit;
+ }
+ Py_ssize_t msg_length;
+ msg = PyUnicode_AsUTF8AndSize(arg, &msg_length);
+ if (msg == NULL) {
+ goto exit;
+ }
+ if (strlen(msg) != (size_t)msg_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _tkinter_tkapp_adderrorinfo_impl(self, msg);
@@ -147,7 +187,17 @@
PyObject *return_value = NULL;
const char *s;
- if (!PyArg_Parse(arg, "s:exprstring", &s)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("exprstring", "str", arg);
+ goto exit;
+ }
+ Py_ssize_t s_length;
+ s = PyUnicode_AsUTF8AndSize(arg, &s_length);
+ if (s == NULL) {
+ goto exit;
+ }
+ if (strlen(s) != (size_t)s_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _tkinter_tkapp_exprstring_impl(self, s);
@@ -173,7 +223,17 @@
PyObject *return_value = NULL;
const char *s;
- if (!PyArg_Parse(arg, "s:exprlong", &s)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("exprlong", "str", arg);
+ goto exit;
+ }
+ Py_ssize_t s_length;
+ s = PyUnicode_AsUTF8AndSize(arg, &s_length);
+ if (s == NULL) {
+ goto exit;
+ }
+ if (strlen(s) != (size_t)s_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _tkinter_tkapp_exprlong_impl(self, s);
@@ -199,7 +259,17 @@
PyObject *return_value = NULL;
const char *s;
- if (!PyArg_Parse(arg, "s:exprdouble", &s)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("exprdouble", "str", arg);
+ goto exit;
+ }
+ Py_ssize_t s_length;
+ s = PyUnicode_AsUTF8AndSize(arg, &s_length);
+ if (s == NULL) {
+ goto exit;
+ }
+ if (strlen(s) != (size_t)s_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _tkinter_tkapp_exprdouble_impl(self, s);
@@ -225,7 +295,17 @@
PyObject *return_value = NULL;
const char *s;
- if (!PyArg_Parse(arg, "s:exprboolean", &s)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("exprboolean", "str", arg);
+ goto exit;
+ }
+ Py_ssize_t s_length;
+ s = PyUnicode_AsUTF8AndSize(arg, &s_length);
+ if (s == NULL) {
+ goto exit;
+ }
+ if (strlen(s) != (size_t)s_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _tkinter_tkapp_exprboolean_impl(self, s);
@@ -296,7 +376,17 @@
PyObject *return_value = NULL;
const char *name;
- if (!PyArg_Parse(arg, "s:deletecommand", &name)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("deletecommand", "str", arg);
+ goto exit;
+ }
+ Py_ssize_t name_length;
+ name = PyUnicode_AsUTF8AndSize(arg, &name_length);
+ if (name == NULL) {
+ goto exit;
+ }
+ if (strlen(name) != (size_t)name_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _tkinter_tkapp_deletecommand_impl(self, name);
@@ -594,7 +684,13 @@
PyObject *return_value = NULL;
int new_val;
- if (!PyArg_Parse(arg, "i:setbusywaitinterval", &new_val)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ new_val = _PyLong_AsInt(arg);
+ if (new_val == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _tkinter_setbusywaitinterval_impl(module, new_val);
@@ -638,4 +734,4 @@
#ifndef _TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF
#define _TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF
#endif /* !defined(_TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF) */
-/*[clinic end generated code: output=a9d45a90cde94980 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=d84b0e794824c511 input=a9049054013a1b77]*/