summaryrefslogtreecommitdiffstats
path: root/Modules/resource.c
diff options
context:
space:
mode:
authorOleg Iarygin <oleg@arhadthedev.net>2022-07-29 11:48:11 (GMT)
committerGitHub <noreply@github.com>2022-07-29 11:48:11 (GMT)
commita739ee412cb2342554a70f30faaa3b7752bbd0a4 (patch)
tree2a8b53bc7368ebf0905a2a4c010a704c768f3ab2 /Modules/resource.c
parente003b64f40fa28954ec967024fa811adff6cffe7 (diff)
downloadcpython-a739ee412cb2342554a70f30faaa3b7752bbd0a4.zip
cpython-a739ee412cb2342554a70f30faaa3b7752bbd0a4.tar.gz
cpython-a739ee412cb2342554a70f30faaa3b7752bbd0a4.tar.bz2
gh-94512: Fix forced arg format in AC-processed resource (GH-94515)
Diffstat (limited to 'Modules/resource.c')
-rw-r--r--Modules/resource.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/Modules/resource.c b/Modules/resource.c
index d8bba2e..a97fb87 100644
--- a/Modules/resource.c
+++ b/Modules/resource.c
@@ -24,8 +24,16 @@ module resource
class pid_t_converter(CConverter):
type = 'pid_t'
format_unit = '" _Py_PARSE_PID "'
+
+ def parse_arg(self, argname, displayname):
+ return """
+ {paramname} = PyLong_AsPid({argname});
+ if ({paramname} == -1 && PyErr_Occurred()) {{{{
+ goto exit;
+ }}}}
+ """.format(argname=argname, paramname=self.parser_name)
[python start generated code]*/
-/*[python end generated code: output=da39a3ee5e6b4b0d input=0c1d19f640d57e48]*/
+/*[python end generated code: output=da39a3ee5e6b4b0d input=5af1c116d56cbb5a]*/
#include "clinic/resource.c.h"
@@ -268,17 +276,15 @@ resource.prlimit
pid: pid_t
resource: int
- [
- limits: object
- ]
+ limits: object = None
/
[clinic start generated code]*/
static PyObject *
resource_prlimit_impl(PyObject *module, pid_t pid, int resource,
- int group_right_1, PyObject *limits)
-/*[clinic end generated code: output=ee976b393187a7a3 input=b77743bdccc83564]*/
+ PyObject *limits)
+/*[clinic end generated code: output=6ebc49ff8c3a816e input=54bb69c9585e33bf]*/
{
struct rlimit old_limit, new_limit;
int retval;
@@ -294,7 +300,7 @@ resource_prlimit_impl(PyObject *module, pid_t pid, int resource,
return NULL;
}
- if (group_right_1) {
+ if (limits != Py_None) {
if (py2rlimit(limits, &new_limit) < 0) {
return NULL;
}