Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(165501)

Unified Diff: Python/compile.c

Issue 23722: During metaclass.__init__, super() of the constructed class does not work
Patch Set: Created 3 years ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« Python/bltinmodule.c ('K') | « Python/bltinmodule.c ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Python/compile.c Sat Dec 03 15:57:00 2016 -0800
+++ b/Python/compile.c Sun Dec 04 22:38:04 2016 +1000
@@ -1967,8 +1967,9 @@
compiler_exit_scope(c);
return 0;
}
+ /* Return __classcell__ if it is referenced, otherwise return None */
if (c->u->u_ste->ste_needs_class_closure) {
- /* store __classcell__ into class namespace */
+ /* Store __classcell__ into class namespace & return it */
str = PyUnicode_InternFromString("__class__");
if (str == NULL) {
compiler_exit_scope(c);
@@ -1983,6 +1984,7 @@
assert(i == 0);
ADDOP_I(c, LOAD_CLOSURE, i);
+ ADDOP(c, DUP_TOP);
str = PyUnicode_InternFromString("__classcell__");
if (!str || !compiler_nameop(c, str, Store)) {
Py_XDECREF(str);
@@ -1992,9 +1994,11 @@
Py_DECREF(str);
}
else {
- /* This happens when nobody references the cell. */
+ /* No methods referenced __class__, so just return None */
assert(PyDict_Size(c->u->u_cellvars) == 0);
+ ADDOP_O(c, LOAD_CONST, Py_None, consts);
}
+ ADDOP_IN_SCOPE(c, RETURN_VALUE);
/* create the code object */
co = assemble(c, 1);
}
« Python/bltinmodule.c ('K') | « Python/bltinmodule.c ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+