Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r54142:171b149844d2 Date: 2012-04-02 10:26 +0200 http://bitbucket.org/pypy/pypy/changeset/171b149844d2/
Log: Export tp_doc. diff --git a/pypy/module/cpyext/test/foo.c b/pypy/module/cpyext/test/foo.c --- a/pypy/module/cpyext/test/foo.c +++ b/pypy/module/cpyext/test/foo.c @@ -176,6 +176,8 @@ {NULL} /* Sentinel */ }; +PyDoc_STRVAR(foo_doc, "foo is for testing."); + static PyTypeObject footype = { PyVarObject_HEAD_INIT(NULL, 0) "foo.foo", /*tp_name*/ @@ -198,7 +200,7 @@ (setattrofunc)foo_setattro, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT, /*tp_flags*/ - 0, /*tp_doc*/ + foo_doc, /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py --- a/pypy/module/cpyext/test/test_typeobject.py +++ b/pypy/module/cpyext/test/test_typeobject.py @@ -20,6 +20,7 @@ assert type(obj) is module.fooType print "type of obj has type", type(type(obj)) print "type of type of obj has type", type(type(type(obj))) + assert module.fooType.__doc__ == "foo is for testing." def test_typeobject_method_descriptor(self): module = self.import_module(name='foo') diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py --- a/pypy/module/cpyext/typeobject.py +++ b/pypy/module/cpyext/typeobject.py @@ -307,6 +307,8 @@ if not space.is_true(space.issubtype(self, space.w_type)): self.flag_cpytype = True self.flag_heaptype = False + if pto.c_tp_doc: + self.w_doc = space.wrap(rffi.charp2str(pto.c_tp_doc)) @bootstrap_function def init_typeobject(space): @@ -624,7 +626,6 @@ Creates an interpreter type from a PyTypeObject structure. """ # missing: - # setting __doc__ if not defined and tp_doc defined # inheriting tp_as_* slots # unsupported: # tp_mro, tp_subclasses _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit