On Tue, May 22, 2012 at 8:40 PM, Eric V. Smith <eric@trueblade.com> wrote:
On 5/22/2012 2:37 PM, Guido van Rossum wrote:
> Okay, I've been convinced that keeping the dynamic path feature is a
> good idea. I am really looking forward to seeing the rationale added
> to the PEP -- that's pretty much the last thing on my list that made
> me hesitate. I'll leave the details of exactly how the parent path is
> referenced up to the implementation team (several good points were
> made), as long as the restriction that sys.path must be modified in
> place is lifted.

I've updated the PEP. Let me know how it looks.

My name is misspelled in it, but otherwise it looks fine.  ;-)

I have not updated the implementation yet. I'm not exactly sure how I'm
going to convert from a path list of unknown origin to ('sys', 'path')
or ('foo', '__path__'). I'll look at it later tonight to see if it's
possible. I'm hoping it doesn't require major surgery to
importlib._bootstrap.

It shouldn't - all you should need is to use getattr(sys.modules[self.modname], self.attr) instead of referencing a parent path object directly.

(The more interesting thing is what to do if the parent module goes away, due to somebody deleting the module out of sys.modules.  The simplest thing to do would probably be to just keep using the cached value in that case.)

Ah crap, I just thought of something - what happens if you reload() a namespace package?  Probably nothing, but should we specify what sort of nothing?  ;-)