Author nkoep
Recipients nkoep
Date 2013-06-23.15:12:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1372000372.42.0.425313116494.issue18287@psf.upfronthosting.co.za>
In-reply-to
Content
I noticed that defining a new type where the tp_name field is NULL causes segfaults, for instance, when calling pydoc on the extension module. This particular segfault traces back to type_module() in Objects/typeobject.c where tp_name is passed to strrchr(). Raising an appropriate exception from PyType_Ready() seems sensible to avoid this kind of issue. The field is also used in two calls to PyErr_Format() in PyType_Ready() itself where it'll cause segfaults if not handled properly.

While we're on the subject, pydoc doesn't list the type documentation  if the tp_name string does not have a dot in it. I didn't research this any further as omitting dots seems to be valid according to the docs. However, at the very least it seems like this side effect should be mentioned in the documentation to avoid confusion when someone omits/forgets the package.<subpackage>.module.type hierarchy in the field definition.

I attached a tiny patch which just jumps to PyType_Ready()'s error label if the field is NULL. I also added a comment about pydoc in the two places of the documentation I could think of where tp_name is mentioned.
History
Date User Action Args
2013-06-23 15:12:52nkoepsetrecipients: + nkoep
2013-06-23 15:12:52nkoepsetmessageid: <1372000372.42.0.425313116494.issue18287@psf.upfronthosting.co.za>
2013-06-23 15:12:52nkoeplinkissue18287 messages
2013-06-23 15:12:51nkoepcreate