From 6ac566cc59acde1a1a1c6c59eda874694b215fa9 Mon Sep 17 00:00:00 2001 From: Larry Hastings Date: Mon, 2 May 2022 12:40:22 -0600 Subject: [PATCH] Fix the closure argument to PyEval_EvalCodeEx. --- .../next/C API/2022-05-02-12-39-33.gh-issue-92173.len2Is.rst | 1 + Objects/funcobject.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/C API/2022-05-02-12-39-33.gh-issue-92173.len2Is.rst diff --git a/Misc/NEWS.d/next/C API/2022-05-02-12-39-33.gh-issue-92173.len2Is.rst b/Misc/NEWS.d/next/C API/2022-05-02-12-39-33.gh-issue-92173.len2Is.rst new file mode 100644 index 00000000000000..c8f9b58bd6393a --- /dev/null +++ b/Misc/NEWS.d/next/C API/2022-05-02-12-39-33.gh-issue-92173.len2Is.rst @@ -0,0 +1 @@ +Fix the ``closure`` argument to :c:func:`PyEval_EvalCodeEx`. diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 1e0cfb7efb479a..32b4155c03e6ae 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -29,7 +29,8 @@ _PyFunction_FromConstructor(PyFrameConstructor *constr) op->func_code = constr->fc_code; op->func_defaults = NULL; op->func_kwdefaults = NULL; - op->func_closure = NULL; + Py_XINCREF(constr->fc_closure); + op->func_closure = constr->fc_closure; Py_INCREF(Py_None); op->func_doc = Py_None; op->func_dict = NULL;