[Python-Dev] importlib is now bootstrapped (and what that means)

Stefan Behnel stefan_ml at behnel.de
Mon Apr 16 13:49:37 CEST 2012


Antoine Pitrou, 16.04.2012 13:13:
> On Mon, 16 Apr 2012 09:54:41 +0200
> Stefan Behnel wrote:
>>
>> The new import cache broke Cython's load of on-the-fly compiled extension
>> modules, which naively used "__import__(module_name)" after building them.
>> I could fix that by moving to "imp.load_dynamic()" (we know where we put
>> the compiled module anyway), although I just noticed that that's not
>> actually documented. So I hope that won't break later on.
> 
> You can call importlib.invalidate_caches().
> http://docs.python.org/dev/library/importlib.html#importlib.invalidate_caches

Well, yes, but imp.load_dynamic() would be the right thing to do for us. Is
there a reason why it's not documented?

I would like to avoid changing the code to load_dynamic() now and then
having to realise that that's going to die in 3.3 final because it somehow
got in the way of the importlob rewrites and is not being considered a
valuable enough public API.

New doc bug ticket:

http://bugs.python.org/issue14594


>> The next thing I noticed is that the old-style level -1 import no longer
>> works, which presumably breaks a *lot* of Cython compiled modules. It used
>> to work in the master branch until two days ago, now it raises a
>> ValueError. We may be able to fix this by copying over CPython's old import
>> code into Cython, but I actually wonder if this was really intended. If
>> this feature wasn't deliberately broken in Py3.0, why break it now?
> 
> Regressions should be reported on the bug tracker IMHO.

It was meant as more of a question for now, but here it goes:

http://bugs.python.org/issue14592

Stefan



More information about the Python-Dev mailing list