8000 gh-64490: Fix refcount error when arguments are packed to tuple in argument clinic by colorfulappl · Pull Request #99233 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-64490: Fix refcount error when arguments are packed to tuple in argument clinic #99233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Replace Py_INCREF with Py_NewRef
  • Loading branch information
colorfulappl committed Nov 24, 2022
commit a876e94a31e425b360cb0f18bb0895a67670af88
5 changes: 2 additions & 3 deletions Lib/test/clinic.test
Original file line number Diff line number Diff line change
Expand Up @@ -3793,8 +3793,7 @@ test_vararg_and_posonly(PyObject *module, PyObject *const *args, Py_ssize_t narg
a = args[0];
__clinic_args = PyTuple_New(nargs - 1);
for (Py_ssize_t i = 0; i < nargs - 1; ++i) {
Py_INCREF(args[1 + i]);
PyTuple_SET_ITEM(__clinic_args, i, args[1 + i]);
PyTuple_SET_ITEM(__clinic_args, i, Py_NewRef(args[1 + i]));
}
return_value = test_vararg_and_posonly_impl(module, a, __clinic_args);

Expand All @@ -3805,7 +3804,7 @@ exit:

static PyObject *
test_vararg_and_posonly_impl(PyObject *module, PyObject *a, PyObject *args)
/*[clinic end generated code: output=c6d0dd2d43a88a7f input=08dc2bf7afbf1613]*/
/*[clinic end generated code: output=081a953b8cbe7617 input=08dc2bf7afbf1613]*/

/*[clinic input]
test_vararg
Expand Down
8 changes: 3 additions & 5 deletions Modules/clinic/_testclinic.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,14 +956,12 @@ def parser_body(prototype, *fields, declarations=''):
parser_code.append(normalize_snippet("""
%s = PyTuple_New(%s);
for (Py_ssize_t i = 0; i < %s; ++i) {{
Py_INCREF(args[%d + i]);
PyTuple_SET_ITEM(%s, i, args[%d + i]);
PyTuple_SET_ITEM(%s, i, Py_NewRef(args[%d + i]));
}}
""" % (
p.converter.parser_name,
left_args,
left_args,
max_pos,
p.converter.parser_name,
max_pos
), indent=4))
Expand Down
0