[issue6386] importing yields unexpected results when initial script is a symbolic link

2014-02-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 47c31e7d3779 by Brett Cannon in branch 'default':
Issue #6386: When executing a script that's a symlink, the directory
http://hg.python.org/cpython/rev/47c31e7d3779

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6386] importing yields unexpected results when initial script is a symbolic link

2014-02-06 Thread Brett Cannon

Brett Cannon added the comment:

Thanks for the path, Senko! Tweaked the wording a bit as the "current 
directory" part was accurate for when you're in the REPL.

--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6386] importing yields unexpected results when initial script is a symbolic link

2014-02-03 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis :


--
nosy: +Arfrever

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6386] importing yields unexpected results when initial script is a symbolic link

2014-02-03 Thread Brett Cannon

Changes by Brett Cannon :


--
assignee:  -> brett.cannon

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6386] importing yields unexpected results when initial script is a symbolic link

2014-02-03 Thread Mark Lawrence

Changes by Mark Lawrence :


--
nosy:  -BreamoreBoy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6386] importing yields unexpected results when initial script is a symbolic link

2013-07-06 Thread Senko Rasic

Senko Rasic added the comment:

Yep, signed.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6386] importing yields unexpected results when initial script is a symbolic link

2013-07-06 Thread Brett Cannon

Brett Cannon added the comment:

Senko, could you sign the contributor agreement 
(http://python.org/psf/contrib/contrib-form/) so we can use your patch?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6386] importing yields unexpected results when initial script is a symbolic link

2013-07-06 Thread Senko Rasic

Senko Rasic added the comment:

Patch for modifying the modules part of tutorial with the changes suggested by 
jamadagni (reworded slightly so the note is outside the itemized list).

--
keywords: +patch
nosy: +senko
Added file: http://bugs.python.org/file30822/tutorial-symlink-syspath-note.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6386] importing yields unexpected results when initial script is a symbolic link

2013-05-27 Thread Nick Coghlan

Nick Coghlan added the comment:

That's fair - reopening this as a docs bug.

--
assignee: brett.cannon -> 
components: +Documentation
resolution: wont fix -> 
stage: test needed -> needs patch
status: closed -> open
type: behavior -> enhancement
versions:  -Python 3.2

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6386] importing yields unexpected results when initial script is a symbolic link

2013-05-27 Thread Shriramana Sharma

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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6386] importing yields unexpected results when initial script is a symbolic link

2013-05-27 Thread Nick Coghlan

Nick Coghlan added the comment:

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

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6386] importing yields unexpected results when initial script is a symbolic link

2013-05-27 Thread R. David Murray

R. David Murray added the comment:

When a script is executed by python, it does *not* import from the CWD, it 
imports from the *location of the script*.  From this, then, you can see that 
there are two possible interpretations of "the location of the script" when the 
script is a symlink, and we have chosen the more secure (and practical) one: 
the location of the real script file.

--
nosy: +r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6386] importing yields unexpected results when initial script is a symbolic link

2013-05-27 Thread Shriramana Sharma

Shriramana Sharma added the comment:

I'm sorry but I don't get why this is a WONTFIX. I reported what is (now) 
apparently a dup: issue 18067. Just like the OP of this bug, I feel that in 
doing testing and such, one would naturally symlink and expect the library in 
the *current* directory to be imported. 

And about the CWD, I have demonstrated in issue 18067 how the CWD is in fact 
reported to be the directory of the *source* of the symlink (i.e. the dir 
containing the symlink inode) and not the *target* of the symlink. This is 
precisely what is frustrating about this bug: the fact that Python does not 
import something from a directory which it reports to be the current directory 
as per os.getcwd(). 

While I myself lack the internal CPython code knowledge to fix this, I can't 
imagine this would be too difficult to fix, given that os.getcwd() already 
reports the correct current directory -- in setting up the import path list, 
you just have to use that i.o. whatever else you are using now.

Thanks.

--
nosy: +jamadagni

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6386] importing yields unexpected results when initial script is a symbolic link

2013-04-18 Thread Brett Cannon

Brett Cannon added the comment:

In case someone wants to reproduce:

  mkdir pkg
  echo "import tester" > pkg/symlinked.py
  ln -s pkg/symlinked.py linked.py
  echo "print('HIT')" > tester.py

That fails because Python assumes you are in the pkg directory, not the 
directory you started execution. This makes sense to me. If you used a hard 
link then this isn't a problem. Python treats a symlink as a redirect, which 
means it works where the redirect tells it to and doesn't try to confuse things 
by considering 2 different locations to be the cwd for imports.

Closing as "won't fix" since I think it would be more confusing to support both 
a symlink directory and the cwd.

--
assignee:  -> brett.cannon
resolution:  -> wont fix
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6386] importing yields unexpected results when initial script is a symbolic link

2013-04-18 Thread Mark Lawrence

Mark Lawrence added the comment:

It will be difficult to take this forward owing to the problem description in 
msg89914 being limited to "importing from normal files in the same directory 
does not work".  Plus any problems back then may well have been fixed due to 
the reworking of the import mechanism by somebody who apparently has spent 10 
years as a Python core developer.  Congratulations :)

--
nosy: +BreamoreBoy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6386] importing yields unexpected results when initial script is a symbolic link

2012-11-12 Thread Eric Snow

Changes by Eric Snow :


--
nosy: +eric.snow

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6386] importing yields unexpected results when initial script is a symbolic link

2012-11-09 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +brett.cannon, ncoghlan
versions: +Python 3.3, Python 3.4 -Python 3.1

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6386] importing yields unexpected results when initial script is a symbolic link

2010-07-10 Thread Mark Lawrence

Changes by Mark Lawrence :


--
stage:  -> unit test needed
versions: +Python 3.2 -Python 2.4, Python 2.5, Python 2.6, Python 3.0

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6386] importing yields unexpected results when initial script is a symbolic link

2009-06-30 Thread jan matejek

Changes by jan matejek :


--
nosy: +matejcik

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6386] importing yields unexpected results when initial script is a symbolic link

2009-06-30 Thread jbeulich

New submission from jbeulich :

Due to the way PySys_SetArgv() works, when the initial script is a
symbolic link, importing from normal files in the same directory does
not work. This is particularly surprising when the work tree is a
symlinked clone (cp -s) of an original (i.e. snapshot) tree with a few
modifications (patches) applied to one or more of the modules imported
from: Due the the erratum, the modifications made will appear to not
take effect until one realizes that the wrong module is being imported from.

The solution would in my opinion be to not only add the path left after
the readlink()/realpath() processing to the import search path list, but
also any intermediately encountered ones (in the order processed) as
long as the leaf component continues to be a symlink.

(Note: It seems pointless to use readlink() in the current [3.1 and
earlier] implementation, since the result gets passed to realpath()
anyway. Also, the documentation doesn't seem to mention this behavior,
and from the sources it remains unclear why this processing is needed at
all.)

--
messages: 89914
nosy: jbeulich
severity: normal
status: open
title: importing yields unexpected results when initial script is a symbolic 
link
type: behavior
versions: Python 2.4, Python 2.5, Python 2.6, Python 2.7, Python 3.0, Python 3.1

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com