[Python-Dev] nested extension modules?
David Abrahams
dave@boost-consulting.com
Mon, 19 Aug 2002 20:35:53 -0400
- Previous message: [Python-Dev] Re: [Python-checkins] python/dist/src/Objects bufferobject.c,2.19,2.20 complexobject.c,2.62,2.63 floatobject.c,2.114,2.115 intobject.c,2.91,2.92 stringobject.c,2.180,2.181 tupleobject.c,2.71,2.72
- Next message: [Python-Dev] nested extension modules?
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Hi,
Using the source (Luke), I was trying to figure out the best way to add a
nested submodule from within an extension module. I noticed that the module
initialization code will set the module name from the package context (if
set), altogether discarding any name passed explicitly:
[modsupport.c: Py_InitModule4()]
...
if (_Py_PackageContext != NULL) {
char *p = strrchr(_Py_PackageContext, '.');
if (p != NULL && strcmp(name, p+1) == 0) {
name = _Py_PackageContext;
_Py_PackageContext = NULL;
}
}
This _Py_PackageContext is set up from within _PyImport_LoadDynamicModule
[importdl.c:]
...
oldcontext = _Py_PackageContext;
_Py_PackageContext = packagecontext;
(*p)();
_Py_PackageContext = oldcontext;
IIUC, this means that when an extension module is loaded as part of a
package, any submodules I create my calling Py_InitModule<whatever> will
come out with the same name.
Questions:
a. Have I got the analysis right?
b. Is there a more-sanctioned way around this other than touching
_Py_PackageContext (which seems to be intended to be private)
TIA,
Dave
-----------------------------------------------------------
David Abrahams * Boost Consulting
dave@boost-consulting.com * http://www.boost-consulting.com
- Previous message: [Python-Dev] Re: [Python-checkins] python/dist/src/Objects bufferobject.c,2.19,2.20 complexobject.c,2.62,2.63 floatobject.c,2.114,2.115 intobject.c,2.91,2.92 stringobject.c,2.180,2.181 tupleobject.c,2.71,2.72
- Next message: [Python-Dev] nested extension modules?
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]