gh-94512: Fix forced arg format in AC-processed resource (GH-94515)

This commit is contained in:
Oleg Iarygin 2022-07-29 14:48:11 +03:00 committed by GitHub
parent e003b64f40
commit a739ee412c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 30 deletions

View file

@ -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;
}