summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-12-04 16:23:42 (GMT)
committerGuido van Rossum <guido@python.org>2001-12-04 16:23:42 (GMT)
commit6b70599450777a8b911f0eff44b18cd22f1c1e1e (patch)
tree10bb79dc54602e3226dd68774994e15a6d1af2b9 /Python
parentebca9fc1ba23e58d734b9ab422da6a64fa4d72e2 (diff)
downloadcpython-6b70599450777a8b911f0eff44b18cd22f1c1e1e.zip
cpython-6b70599450777a8b911f0eff44b18cd22f1c1e1e.tar.gz
cpython-6b70599450777a8b911f0eff44b18cd22f1c1e1e.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 'Python')
-rw-r--r--Python/structmember.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Python/structmember.c b/Python/structmember.c
index aa0ea9f..34310b8 100644
--- a/Python/structmember.c
+++ b/Python/structmember.c
@@ -129,6 +129,12 @@ PyMember_GetOne(char *addr, PyMemberDef *l)
v = Py_None;
Py_INCREF(v);
break;
+ case T_OBJECT_EX:
+ v = *(PyObject **)addr;
+ if (v == NULL)
+ PyErr_SetString(PyExc_AttributeError, l->name);
+ Py_XINCREF(v);
+ break;
default:
PyErr_SetString(PyExc_SystemError, "bad memberdescr type");
v = NULL;
@@ -175,7 +181,7 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v)
PyErr_SetString(PyExc_RuntimeError, "restricted attribute");
return -1;
}
- if (v == NULL && l->type != T_OBJECT) {
+ if (v == NULL && l->type != T_OBJECT_EX && l->type != T_OBJECT) {
PyErr_SetString(PyExc_TypeError,
"can't delete numeric/char attribute");
return -1;
@@ -246,6 +252,7 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v)
}
break;
case T_OBJECT:
+ case T_OBJECT_EX:
Py_XINCREF(v);
oldv = *(PyObject **)addr;
*(PyObject **)addr = v;