[Python-3000] Interest in PEP for callbacks on module import

Christian Heimes lists at cheimes.de
Sat Dec 8 22:49:21 CET 2007


Phillip J. Eby wrote:
> Note that in my implementation, an entry is added to sys.modules 
> immediately, so this scenario can't happen without *replacing* the 
> sys.modules entry.

I like to separate the implementation of the post import hook from lazy
modules. I think that the hook and lazy modules can be implemented
independently.

>> * module is loaded with __import__() but callbacks weren't fired yet
>>   o the existing import mechanism is called
>>   o after the module is loaded and inserted into sys.modules
>>     the callbacks are fired in reverse order (FILO).
> 
> Why not FIFO?

I don't have a strong opinion on the order. I can life with FIFO, too.
What should happen if a post import hook fails? Should the error be
catch and reported or should the chain stop?

Christian


More information about the Python-3000 mailing list