[Python-Dev] Finding the module from PyTypeObject?

Nick Bastin nbastin at opnet.com
Wed Sep 29 19:24:23 CEST 2004

On Sep 29, 2004, at 12:56 PM, Michael Hudson wrote:

> Nick Bastin <nbastin at opnet.com> writes:
>> Is there any way to (reliably) find the module that defined the class
>> represented by a given PyTypeObject in C?
> Not especially appropriate for python-dev...
> I think the answer depends on what you mean by "reliably".  __module__
> is a good first bet, but can be defeated with sufficient malice (or
> mere inattention, in the case of types defined by C).

Ok, maybe more appropriately, what do people think of adding a 
PyType_GetModule (PyTypeObject *) which basically functions like 
type_module(PyTypeObject *, void *) (in Objects/typeobject.c) to the 
public C API, rather than having to dig around in the object 


More information about the Python-Dev mailing list