Shriramana Sharma added the comment:

> The current behaviour is also needed to sanely support Python 
> scripts symlinked from Linux /bin directories.

OK that clinched it for me -- I can't argue against that! And obviously it is 
not meaningful to copy/symlink *all* the current-directory modules a particular 
script depends upon to the symlink directory as well. And searching both 
directories (containing the source and target of the symlink) is not good for 
security I guess.

And I also checked the contents of sys.path with my test case -- and sure 
enough the directory corresponding to the actual output was printed. Just that 
sys.path is different from os.getcwd() needs some effort to bring into mind.

So I think someone should please clearly mention this behaviour in the 
documentation under 
http://docs.python.org/3/tutorial/modules.html#the-module-search-path and the 
Py2 equivalent. Specifically this point needs clarification:

""the directory containing the input script (or the current directory).""

It would be best to remove the text in parantheses (which immediately makes one 
think of os.getcwd()) and add a clarification like:

Note that on filesystems that support symlinks, this means the directory 
containing the actual script file. Symlinks to the script may be present 
elsewhere and may be used to invoke the script, but the directories containing 
those symlinks will *not* be searched for dependency modules.

Thank you very much for these clarifications and for your work on Python! 
Please do add the above documentation clarification, though.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue6386>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to