[issue1387483] sys.path

Charles-François Natali report at bugs.python.org
Fri Apr 5 09:06:09 CEST 2013


Charles-François Natali added the comment:

> I am not sure about what use cases could be broken by the above change, do you have examples?
> Normal use cases of symbolic links have to do with linking entire folders, not individual files, and that behaviour would not be broken by  such a hypothetical change, I think.

For example:

/tmp/
    foo/
        foo.py
        libfoo.py

    foo.py -> /tmp/foo/foo.py

With foo.py containing "import libfoo".

Now, calling /tmp/foo.py works because sys.path[0] ==
dirname(realpath("/tmp/foo.py")) == dirname("/tmp/foo/foo.py") ==
"/tmp/foo.

If we change sys.path[0] to not dereference the symlink (that's how I
understood your suggestion, maybe I got it wrong), it will now be
/tmp, and importing libfoo will fail.

That's AFAICT exacyly the problem reported by the OP on OS-X.

----------
title: sys.path[0] when executed thru a symbolic link -> sys.path

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1387483>
_______________________________________


More information about the Python-bugs-list mailing list