summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-08-17 17:03:47 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-08-17 17:03:47 (GMT)
commit01fc6cd056ba5b389af55c58d46fbe1a33767d0c (patch)
tree85258354d5f702a0783481f0cda64e8305ebbce1 /Objects
parentd9f23d200426983bfb2aadf254fb84d2447a70e8 (diff)
downloadcpython-01fc6cd056ba5b389af55c58d46fbe1a33767d0c.zip
cpython-01fc6cd056ba5b389af55c58d46fbe1a33767d0c.tar.gz
cpython-01fc6cd056ba5b389af55c58d46fbe1a33767d0c.tar.bz2
make __doc__ mutable on heaptypes (closes #12773)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 33becb3..640d14f 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -588,6 +588,15 @@ type_get_doc(PyTypeObject *type, void *context)
return result;
}
+static int
+type_set_doc(PyTypeObject *type, PyObject *value, void *context)
+{
+ if (!check_set_special_type_attr(type, value, "__doc__"))
+ return -1;
+ PyType_Modified(type);
+ return PyDict_SetItemString(type->tp_dict, "__doc__", value);
+}
+
static PyObject *
type___instancecheck__(PyObject *type, PyObject *inst)
{
@@ -623,7 +632,7 @@ static PyGetSetDef type_getsets[] = {
{"__abstractmethods__", (getter)type_abstractmethods,
(setter)type_set_abstractmethods, NULL},
{"__dict__", (getter)type_dict, NULL, NULL},
- {"__doc__", (getter)type_get_doc, NULL, NULL},
+ {"__doc__", (getter)type_get_doc, (setter)type_set_doc, NULL},
{0}
};