8000 bpo-43693: Un-revert commits 2c1e258 and b2bf2bc. by ericsnowcurrently · Pull Request #26577 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-43693: Un-revert commits 2c1e258 and b2bf2bc. #26577

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
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
Fix refleaks.
  • Loading branch information
ericsnowcurrently committed Jun 7, 2021
commit 1fb813c21cf11fd3a5d5319951d6e918f3677b04
12 changes: 6 additions & 6 deletions Objects/codeobject.c
8000
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,7 @@ PyObject *
_PyCode_GetVarnames(PyCodeObject *co)
{
if (co->co_varnames == NULL) {
// PyCodeObject owns this reference.
co->co_varnames = get_localsplus_names(co, CO_FAST_LOCAL,
co->co_nlocals);
if (co->co_varnames == NULL) {
Expand All @@ -1057,6 +1058,7 @@ PyObject *
_PyCode_GetCellvars(PyCodeObject *co)
{
if (co->co_cellvars == NULL) {
// PyCodeObject owns this reference.
co->co_cellvars = get_localsplus_names(co, CO_FAST_CELL,
co->co_ncellvars);
if (co->co_cellvars == NULL) {
Expand All @@ -1071,6 +1073,7 @@ PyObject *
_PyCode_GetFreevars(PyCodeObject *co)
{
if (co->co_freevars == NULL) {
// PyCodeObject owns this reference.
co->co_freevars = get_localsplus_names(co, CO_FAST_FREE,
co->co_nfreevars);
if (co->co_freevars == NULL) {
Expand Down Expand Up @@ -1517,6 +1520,7 @@ code_replace_impl(PyCodeObject *self, int co_argcount,
return NULL;
}

PyCodeObject *co = NULL;
PyObject *varnames = NULL;
PyObject *cellvars = NULL;
PyObject *freevars = NULL;
Expand All @@ -1542,21 +1546,17 @@ code_replace_impl(PyCodeObject *self, int co_argcount,
co_freevars = freevars;
}

PyCodeObject *co = PyCode_NewWithPosOnlyArgs(
co = PyCode_NewWithPosOnlyArgs(
co_argcount, co_posonlyargcount, co_kwonlyargcount, co_nlocals,
co_stacksize, co_flags, (PyObject*)co_code, co_consts, co_names,
co_varnames, co_freevars, co_cellvars, co_filename, co_name,
co_firstlineno, (PyObject*)co_linetable, (PyObject*)co_exceptiontable);
if (co == NULL) {
goto error;
}
return (PyObject *)co;

error:
Py_XDECREF(varnames);
Py_XDECREF(cellvars);
Py_XDECREF(freevars);
return NULL;
return (PyObject *)co;
}

/*[clinic input]
Expand Down
1 change: 1 addition & 0 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,7 @@ compiler_make_closure(struct compiler *c, PyCodeObject *co, Py_ssize_t flags,
c->u->u_name,
co->co_name,
freevars);
Py_DECREF(freevars);
return 0;
}
ADDOP_I(c, LOAD_CLOSURE, arg);
Expand Down
1 change: 1 addition & 0 deletions Python/suggestions.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ offer_suggestions_for_name_error(PyNameErrorObject *exc)
return NULL;
}
PyObject *dir = PySequence_List(varnames);
Py_DECREF(varnames);
Py_DECREF(code);
if (dir == NULL) {
return NULL;
Expand Down
0