summaryrefslogtreecommitdiffstats
path: root/Modules/clinic/resource.c.h
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-12-25 11:23:47 (GMT)
committerGitHub <noreply@github.com>2018-12-25 11:23:47 (GMT)
commit32d96a2b5bc3136d45a66adbdb45fac351b520ce (patch)
treeacf51c9945f764ab103597c9cba376f154aa600d /Modules/clinic/resource.c.h
parent65ce60aef150776f884715b4315a10a0d6ae769e (diff)
downloadcpython-32d96a2b5bc3136d45a66adbdb45fac351b520ce.zip
cpython-32d96a2b5bc3136d45a66adbdb45fac351b520ce.tar.gz
cpython-32d96a2b5bc3136d45a66adbdb45fac351b520ce.tar.bz2
bpo-23867: Argument Clinic: inline parsing code for a single positional parameter. (GH-9689)
Diffstat (limited to 'Modules/clinic/resource.c.h')
-rw-r--r--Modules/clinic/resource.c.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/Modules/clinic/resource.c.h b/Modules/clinic/resource.c.h
index cd9fae1..0a66f8f 100644
--- a/Modules/clinic/resource.c.h
+++ b/Modules/clinic/resource.c.h
@@ -19,7 +19,13 @@ resource_getrusage(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int who;
- if (!PyArg_Parse(arg, "i:getrusage", &who)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ who = _PyLong_AsInt(arg);
+ if (who == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = resource_getrusage_impl(module, who);
@@ -45,7 +51,13 @@ resource_getrlimit(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int resource;
- if (!PyArg_Parse(arg, "i:getrlimit", &resource)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ resource = _PyLong_AsInt(arg);
+ if (resource == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = resource_getrlimit_impl(module, resource);
@@ -157,4 +169,4 @@ exit:
#ifndef RESOURCE_PRLIMIT_METHODDEF
#define RESOURCE_PRLIMIT_METHODDEF
#endif /* !defined(RESOURCE_PRLIMIT_METHODDEF) */
-/*[clinic end generated code: output=637ed2c42bde5ca6 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=b16a9149639081fd input=a9049054013a1b77]*/