[Python-checkins] Fix the closure argument to PyEval_EvalCodeEx. (GH-92175)

markshannon webhook-mailer at python.org
Mon May 2 16:08:31 EDT 2022


https://github.com/python/cpython/commit/c96da83a8ed020c026c3f080e0b646f553524c85
commit: c96da83a8ed020c026c3f080e0b646f553524c85
branch: main
author: larryhastings <larry at hastings.org>
committer: markshannon <mark at hotpy.org>
date: 2022-05-02T14:08:22-06:00
summary:

Fix the closure argument to PyEval_EvalCodeEx. (GH-92175)

files:
A Misc/NEWS.d/next/C API/2022-05-02-12-39-33.gh-issue-92173.len2Is.rst
M Objects/funcobject.c

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 0000000000000..c8f9b58bd6393
--- /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 1e0cfb7efb479..32b4155c03e6a 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;



More information about the Python-checkins mailing list