Message194674
| Author |
eli.bendersky |
| Recipients |
Arfrever, Robin.Schreiber, asvetlov, effbot, eli.bendersky, pitrou |
| Date |
2013年08月08日.13:56:34 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1375970194.83.0.231209418764.issue15651@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Thanks Antoine. I think I understand the patch better now. Just a couple small questions and otherwise LGTM
This code in the beginning in PyInit__elementtree:
m = PyState_FindModule(&elementtreemodule);
if (m) {
Py_INCREF(m);
return m;
}
Can you explain what use case it tries to cover? I couldn't find similar code in other modules we have that implement PEP 3121 (_csv, readline, io, etc.)
This code has at least one adverse effect, for testing. The problem with re-importing _elementtree I raised in http://mail.python.org/pipermail/python-dev/2013-August/127766.html is solved by moving to PEP 3121, but this piece of code above ruins it. This is because I want to set sys.modules['pyexpat'] = None and re-import _elementtree (this is what support.import_fresh_module does). But with this code in place, if _elementtree was imported any time in the past (say, in a previous test), I'll just get the instance back without attempting to do the full module initialization.
>> I don't see a call to PyState_AddModule. What am I missing?
>It is called implicitly when an extension module is imported.
Do you think this should be documented in the C API docs? The way they read now, it seems that calling PyState_AddModule is needed manually by extension writers. |
|