summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2016-12-05 06:59:22 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2016-12-05 06:59:22 (GMT)
commitd77e5b7211e8daf22f2b3e0df124393bca504c38 (patch)
tree5e012ef2dbd2cf633d998cbb4ac780302bd30c73 /Objects
parentde4ae3d4869e88dda8bfbad24880cb398160a7a0 (diff)
parent19d246745d9d013c12e9560dd020d778381780fb (diff)
downloadcpython-d77e5b7211e8daf22f2b3e0df124393bca504c38.zip
cpython-d77e5b7211e8daf22f2b3e0df124393bca504c38.tar.gz
cpython-d77e5b7211e8daf22f2b3e0df124393bca504c38.tar.bz2
Merge #23722 from 3.6
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 186c570..0af1534 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2687,9 +2687,16 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
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();