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

Delta Between Two Patch Sets: Objects/typeobject.c

Issue 23722: During metaclass.__init__, super() of the constructed class does not work
Left Patch Set: Created 3 years ago
Right Patch Set: Created 3 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
LEFTRIGHT
(no file at all)
1 /* Type object implementation */ 1 /* Type object implementation */
2 2
3 #include "Python.h" 3 #include "Python.h"
4 #include "frameobject.h" 4 #include "frameobject.h"
5 #include "structmember.h" 5 #include "structmember.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 8
9 9
10 /* Support type attribute cache */ 10 /* Support type attribute cache */
(...skipping 2669 matching lines...) Expand 10 before | Expand all | Expand 10 after
2680 /* Always override allocation strategy to use regular heap */ 2680 /* Always override allocation strategy to use regular heap */
2681 type->tp_alloc = PyType_GenericAlloc; 2681 type->tp_alloc = PyType_GenericAlloc;
2682 if (type->tp_flags & Py_TPFLAGS_HAVE_GC) { 2682 if (type->tp_flags & Py_TPFLAGS_HAVE_GC) {
2683 type->tp_free = PyObject_GC_Del; 2683 type->tp_free = PyObject_GC_Del;
2684 type->tp_traverse = subtype_traverse; 2684 type->tp_traverse = subtype_traverse;
2685 type->tp_clear = subtype_clear; 2685 type->tp_clear = subtype_clear;
2686 } 2686 }
2687 else 2687 else
2688 type->tp_free = PyObject_Del; 2688 type->tp_free = PyObject_Del;
2689 2689
2690 /* store type in class' cell */ 2690 /* store type in class' cell if one is supplied */
2691 cell = _PyDict_GetItemId(dict, &PyId___classcell__); 2691 cell = _PyDict_GetItemId(dict, &PyId___classcell__);
2692 if (cell != NULL && PyCell_Check(cell)) { 2692 if (cell != NULL) {
2693 /* At least one method requires a reference to its defining class */
2694 if (!PyCell_Check(cell)) {
2695 PyErr_Format(PyExc_TypeError,
2696 "__classcell__ must be a nonlocal cell, not %.200R",
2697 Py_TYPE(cell));
2698 goto error;
2699 }
2693 PyCell_Set(cell, (PyObject *) type); 2700 PyCell_Set(cell, (PyObject *) type);
2694 _PyDict_DelItemId(dict, &PyId___classcell__); 2701 _PyDict_DelItemId(dict, &PyId___classcell__);
2695 PyErr_Clear(); 2702 PyErr_Clear();
2696 } 2703 }
2697 2704
2698 /* Initialize the rest */ 2705 /* Initialize the rest */
2699 if (PyType_Ready(type) < 0) 2706 if (PyType_Ready(type) < 0)
2700 goto error; 2707 goto error;
2701 2708
2702 /* Put the proper slots in place */ 2709 /* Put the proper slots in place */
(...skipping 4864 matching lines...) Expand 10 before | Expand all | Expand 10 after
7567 0, /* tp_base */ 7574 0, /* tp_base */
7568 0, /* tp_dict */ 7575 0, /* tp_dict */
7569 super_descr_get, /* tp_descr_get */ 7576 super_descr_get, /* tp_descr_get */
7570 0, /* tp_descr_set */ 7577 0, /* tp_descr_set */
7571 0, /* tp_dictoffset */ 7578 0, /* tp_dictoffset */
7572 super_init, /* tp_init */ 7579 super_init, /* tp_init */
7573 PyType_GenericAlloc, /* tp_alloc */ 7580 PyType_GenericAlloc, /* tp_alloc */
7574 PyType_GenericNew, /* tp_new */ 7581 PyType_GenericNew, /* tp_new */
7575 PyObject_GC_Del, /* tp_free */ 7582 PyObject_GC_Del, /* tp_free */
7576 }; 7583 };
LEFTRIGHT

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