summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-12-04 17:13:22 (GMT)
committerGuido van Rossum <guido@python.org>2001-12-04 17:13:22 (GMT)
commit64b206c19e764d12f61681359544938c45912262 (patch)
tree2165d27367e6cde216f1929d0ab97680f07a3550 /Objects
parentbb7775a6aebb00d85a2ecd7c2d907c8abbf98446 (diff)
downloadcpython-64b206c19e764d12f61681359544938c45912262.zip
cpython-64b206c19e764d12f61681359544938c45912262.tar.gz
cpython-64b206c19e764d12f61681359544938c45912262.tar.bz2
Fix SF bug #486144: Uninitialized __slot__ vrbl is None.
There's now a new structmember code, T_OBJECT_EX, which is used for all __slot__ variables (except __weakref__, which has special behavior anyway). This new code raises AttributeError when the variable is NULL rather than converting NULL to None.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 6fc5d02..16591cf 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -1059,11 +1059,13 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
for (i = 0; i < nslots; i++, mp++) {
mp->name = PyString_AS_STRING(
PyTuple_GET_ITEM(slots, i));
- mp->type = T_OBJECT;
+ mp->type = T_OBJECT_EX;
mp->offset = slotoffset;
if (base->tp_weaklistoffset == 0 &&
- strcmp(mp->name, "__weakref__") == 0)
+ strcmp(mp->name, "__weakref__") == 0) {
+ mp->type = T_OBJECT;
type->tp_weaklistoffset = slotoffset;
+ }
slotoffset += sizeof(PyObject *);
}
}