bpo-23867: Argument Clinic: inline parsing code for a single positional parameter. (GH-9689)
diff --git a/Modules/clinic/_sre.c.h b/Modules/clinic/_sre.c.h
index fbc5ba4..e8a3665 100644
--- a/Modules/clinic/_sre.c.h
+++ b/Modules/clinic/_sre.c.h
@@ -47,7 +47,13 @@
int character;
int _return_value;
- if (!PyArg_Parse(arg, "i:ascii_iscased", &character)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ character = _PyLong_AsInt(arg);
+ if (character == -1 && PyErr_Occurred()) {
goto exit;
}
_return_value = _sre_ascii_iscased_impl(module, character);
@@ -78,7 +84,13 @@
int character;
int _return_value;
- if (!PyArg_Parse(arg, "i:unicode_iscased", &character)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ character = _PyLong_AsInt(arg);
+ if (character == -1 && PyErr_Occurred()) {
goto exit;
}
_return_value = _sre_unicode_iscased_impl(module, character);
@@ -109,7 +121,13 @@
int character;
int _return_value;
- if (!PyArg_Parse(arg, "i:ascii_tolower", &character)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ character = _PyLong_AsInt(arg);
+ if (character == -1 && PyErr_Occurred()) {
goto exit;
}
_return_value = _sre_ascii_tolower_impl(module, character);
@@ -140,7 +158,13 @@
int character;
int _return_value;
- if (!PyArg_Parse(arg, "i:unicode_tolower", &character)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ character = _PyLong_AsInt(arg);
+ if (character == -1 && PyErr_Occurred()) {
goto exit;
}
_return_value = _sre_unicode_tolower_impl(module, character);
@@ -765,4 +789,4 @@
{
return _sre_SRE_Scanner_search_impl(self);
}
-/*[clinic end generated code: output=5edeca5ec36b5f34 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=7992634045212b26 input=a9049054013a1b77]*/