[Python-3000] PEP 3121 implemented
"Martin v. Löwis"
martin at v.loewis.de
Fri Jun 13 01:47:31 CEST 2008
> Just to mention it, I actually like the new API a lot, and we'll build upon
> that to provide better module cleanup support in later versions. That's
> something that we were missing for a while already.
Thanks. That actually needs proof in reality, as all core modules
currently only have the minimum compatibility with the API.
So if you could actually stress the API before the release, that would
be quite useful.
I found a few aspects to be difficult in porting some existing modules:
- PyModule_Create only creates the module, and doesn't yet put it into
sys.modules. I find that more correct, as initialization might fail,
in which case the regular cleanup should apply (i.e. decrefing the
module). However, _sre relied on the module already being in
sys.modules, as it runs Python code in the init function that already
imports the module being initialized.
- the module object becomes the self parameter to module-level
functions. This broke some modules who have module-level functions
that also act as methods, and where checking for self being NULL
to find out whether it's the function or the method. To fix them,
test whether self is a module (or, vice versa, the expected type).
Regards,
Martin
More information about the Python-3000
mailing list