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

Unified Diff: Objects/typeobject.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
--- a/Objects/typeobject.c Sat Dec 03 15:57:00 2016 -0800
+++ b/Objects/typeobject.c Sun Dec 04 22:38:04 2016 +1000
@@ -2687,9 +2687,16 @@
else
type->tp_free = PyObject_Del;
- /* store type in class' cell */
+ /* store type in class' cell if one is supplied */
cell = _PyDict_GetItemId(dict, &PyId___classcell__);
- if (cell != NULL && PyCell_Check(cell)) {
+ if (cell != NULL) {
+ /* At least one method requires a reference to its defining class */
+ if (!PyCell_Check(cell)) {
+ PyErr_Format(PyExc_TypeError,
+ "__classcell__ must be a nonlocal cell, not %.200R",
+ Py_TYPE(cell));
+ goto error;
+ }
PyCell_Set(cell, (PyObject *) type);
_PyDict_DelItemId(dict, &PyId___classcell__);
PyErr_Clear();
« no previous file with comments | « Lib/test/test_super.py ('k') | Python/bltinmodule.c » ('j') | Python/bltinmodule.c » ('J')

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