On 05/22/2012 09:49 PM, PJ Eby wrote:
On Tue, May 22, 2012 at 8:40 PM, Eric V. Smith <email@example.com mailto:firstname.lastname@example.org> 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. ;-)
Oops, sorry. Fixed (I think).
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 problem isn't the lookup, it's coming up with self.modname and self.attr. As it currently stands, PathFinder.find_module is given the parent path, not the module name and attribute name used to look up the parent path using sys.modules and getattr.