[Python-Dev] PEP 420 - dynamic path computation is missing rationale (original) (raw)

PJ Eby pje at telecommunity.com
Thu May 24 04:58:53 CEST 2012


On Wed, May 23, 2012 at 9:02 PM, Eric V. Smith <eric at trueblade.com> wrote:

On 5/23/2012 8:58 PM, PJ Eby wrote: > On Wed, May 23, 2012 at 8:24 PM, Eric V. Smith <eric at trueblade.com_ _> <mailto:eric at trueblade.com>> wrote: > > I tried this approach and it works fine. The only caveat is that it > assumes that the parent path can always be computed as described above, > independent of what's passed in to PathFinder.loadmodule(). I think > that's reasonable, since loadmodule() itself hard-codes sys.path if the > supplied path is missing. > > > Technically, PEP 302 says that finders aren't allowed to assume their > parent packages are imported: > > """ However, the findmodule() method isn't necessarily always called > during an actual import: meta tools that analyze import dependencies > (such as freeze, Installer or py2exe) don't actually load modules, so a > finder shouldn't /depend/ on the parent package being available in > sys.modules.""" > > OTOH, that's finders, and I think we're dealing with loaders here. > Splitting hairs, perhaps, but at least it's in a good cause. ;-)

I guess I could store the passed-in parent path, and use that if it can't be found through sys.modules. I'm not sure I can conjure up code to test this.

I actually was suggesting that we change PEP 302, if it became an issue. ;-) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20120523/b4347e18/attachment.html>



More information about the Python-Dev mailing list