[issue15864] Package cache doesn't cache packages with overlapping sys.path entries

2012-09-04 Thread Daniel Wagner-Hall
New submission from Daniel Wagner-Hall: Importing the same module twice should only execute its code once, and should only lead to one copy of the classes defined in the module's file. If a subdirectory of $PWD is on $PYTHONPATH, and a package is imported both relative to $PWD and relative to

[issue15864] Package cache doesn't cache packages with overlapping sys.path entries

2012-09-04 Thread R. David Murray
R. David Murray added the comment: Unless I misunderstand you, you are importing the module using two different names, so loading it twice would be the correct behavior. That is, 'foo.bar.baz' is a different thing from 'bar.baz' from Python's point of view. -- nosy: +r.david.murray

[issue15864] Package cache doesn't cache packages with overlapping sys.path entries

2012-09-04 Thread Antoine Pitrou
Antoine Pitrou added the comment: Agreed, I don't think this is a bug. -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15864 ___

[issue15864] Package cache doesn't cache packages with overlapping sys.path entries

2012-09-04 Thread Daniel Wagner-Hall
Daniel Wagner-Hall added the comment: That is indeed the behaviour I'm talking about. In particular I came across this where two libraries imported an exception type using different sys.path traversals, which both led to the same file, and a try-catch didn't catch the exception because it had

[issue15864] Package cache doesn't cache packages with overlapping sys.path entries

2012-09-04 Thread R. David Murray
R. David Murray added the comment: It isn't the file things are defined in that matters, it is how the module object is named. As I said, foo.bar.baz and bar.baz are different objects from Python's point of view, as you found out. -- resolution: - invalid stage: -