summaryrefslogtreecommitdiff
path: root/Python/compile.c
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2017-12-03 23:32:54 +1000
committerGitHub <noreply@github.com>2017-12-03 23:32:54 +1000
commitc8f32aae0aa173e122cf4c0592caec620d0d1de9 (patch)
treea12510b536a9b6bb07c9370c3ef1eb89144dc991 /Python/compile.c
parent2ad350a713360e89ae6d264924cd28f519b8b22c (diff)
downloadcpython-git-c8f32aae0aa173e122cf4c0592caec620d0d1de9.tar.gz
[3.6] bpo-32176: Set CO_NOFREE in the code object constructor (GH-4684)
Previously, CO_NOFREE was set in the compiler, which meant it could end up being set incorrectly when code objects were created directly. Setting it in the constructor based on freevars and cellvars ensures it is always accurate, regardless of how the code object is defined. (cherry picked from commit 078f1814f1a4413a2a0fdb8cf4490ee0fc98ef34)
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c12
1 files changed, 0 insertions, 12 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 797a1840e6..4d525a02c8 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -5190,18 +5190,6 @@ compute_code_flags(struct compiler *c)
/* (Only) inherit compilerflags in PyCF_MASK */
flags |= (c->c_flags->cf_flags & PyCF_MASK);
- n = PyDict_Size(c->u->u_freevars);
- if (n < 0)
- return -1;
- if (n == 0) {
- n = PyDict_Size(c->u->u_cellvars);
- if (n < 0)
- return -1;
- if (n == 0) {
- flags |= CO_NOFREE;
- }
- }
-
return flags;
}