At 10:49 PM 12/8/2007 +0100, Christian Heimes wrote: >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.
Thinking that they can, and actually producing a tested implementation of one that does not, in fact, conflict with the implementation of the other, are two different things. My concern is that I doubt that you can implement the post-import hook without in the process making it difficult for anyone else to implement a lazy module system that works with it. To put it another way, the only way a post-import callback can know that a lazy module has been loaded, is if in some respect the lazy module system *lets* it know. Conversely, if a lazy module system puts a module into sys.modules, a callback system that isn't based on module *objects* (as opposed to module names), will incorrectly believe that the module is already imported and fire the callback... causing the lazy module to be imported, thereby breaking the laziness. And this is only the problem that I'm aware of for *my* concept of lazy modules. There are, I believe, at least two other lazy module libraries out there. So, if you propose to separate the mechanism, I think the burden is on the proposer to show *how* this separation can be achieved. >What should happen if a post import hook fails? Should the error be >catch and reported or should the chain stop? The "Importing" package just lets the chain stop, and the remaining callbacks are never called. My thought is that hooks should be responsible for their own error logging or whatnot. Letting the failure pass through ensures that the programmers who wrote the hooks clean up their code. :) _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com