summaryrefslogtreecommitdiffstats
path: root/Objects/funcobject.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-02-19 15:17:30 (GMT)
committerBenjamin Peterson <benjamin@python.org>2012-02-19 15:17:30 (GMT)
commitb900d6a78c4146143b3f46111e6082e572d93d98 (patch)
tree1c8c78d139762efc3eacf0f1fe8ec982aca5b8b5 /Objects/funcobject.c
parent488a56d2fb3697539fdd6b44df378954066924fe (diff)
downloadcpython-b900d6a78c4146143b3f46111e6082e572d93d98.zip
cpython-b900d6a78c4146143b3f46111e6082e572d93d98.tar.gz
cpython-b900d6a78c4146143b3f46111e6082e572d93d98.tar.bz2
initialize __dict__ if needed
Diffstat (limited to 'Objects/funcobject.c')
-rw-r--r--Objects/funcobject.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index 089356b..6dd91b8 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -832,10 +832,13 @@ cm_get___isabstractmethod__(classmethod *cm, void *closure)
}
static PyObject *
-cm_get___dict__(classmethod *cm, void *closure)
+cm_get___dict__(PyObject *cm, void *closure)
{
- Py_INCREF(cm->cm_dict);
- return cm->cm_dict;
+ PyObject **dictptr = _PyObject_GetDictPtr(cm);
+ if (*dictptr == NULL)
+ *dictptr = PyDict_New();
+ Py_XINCREF(*dictptr);
+ return *dictptr;
}
static PyGetSetDef cm_getsetlist[] = {
@@ -1018,10 +1021,13 @@ sm_get___isabstractmethod__(staticmethod *sm, void *closure)
}
static PyObject *
-sm_get___dict__(staticmethod *sm, void *closure)
+sm_get___dict__(PyObject *sm, void *closure)
{
- Py_INCREF(sm->sm_dict);
- return sm->sm_dict;
+ PyObject **dictptr = _PyObject_GetDictPtr(sm);
+ if (*dictptr == NULL)
+ *dictptr = PyDict_New();
+ Py_XINCREF(*dictptr);
+ return *dictptr;
}
static PyGetSetDef sm_getsetlist[] = {