[issue16957] shutil.which() shouldn't look in working directory on unix-y systems

2013-01-25 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 99db73ce8374 by Serhiy Storchaka in branch '3.3':
Fix pathext test for shutil.which() which was
http://hg.python.org/cpython/rev/99db73ce8374

New changeset ab0ff935126c by Serhiy Storchaka in branch 'default':
Fix pathext test for shutil.which() which was
http://hg.python.org/cpython/rev/ab0ff935126c

--

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



[issue16957] shutil.which() shouldn't look in working directory on unix-y systems

2013-01-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f18d11ab53a0 by Serhiy Storchaka in branch '3.3':
Issue #16957: shutil.which() no longer searches a bare file name in the
http://hg.python.org/cpython/rev/f18d11ab53a0

New changeset 7b51568cfbae by Serhiy Storchaka in branch 'default':
Issue #16957: shutil.which() no longer searches a bare file name in the
http://hg.python.org/cpython/rev/7b51568cfbae

--
nosy: +python-dev

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



[issue16957] shutil.which() shouldn't look in working directory on unix-y systems

2013-01-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Committed. Thank you for for the patch.

--
resolution:  - fixed
stage: commit review - committed/rejected
status: open - closed

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



[issue16957] shutil.which() shouldn't look in working directory on unix-y systems

2013-01-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I have reorganized tests a little.

--
assignee:  - serhiy.storchaka
stage: patch review - commit review
versions: +Python 3.4
Added file: http://bugs.python.org/file28801/shutil_which_cwd4.patch

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



[issue16957] shutil.which() shouldn't look in working directory on unix-y systems

2013-01-21 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

LGTM.

--

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



[issue16957] shutil.which() shouldn't look in working directory on unix-y systems

2013-01-18 Thread Thomas Kluyver

Thomas Kluyver added the comment:

That makes sense - foo/setup.py can be run from the working directory, but you 
can't refer to subdirectories on $PATH like that.

I've added a revised version of the patch.

--
Added file: http://bugs.python.org/file28763/shutil_which_cwd2.patch

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



[issue16957] shutil.which() shouldn't look in working directory on unix-y systems

2013-01-18 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
nosy: +eric.araujo
stage:  - patch review
versions: +Python 3.4

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



[issue16957] shutil.which() shouldn't look in working directory on unix-y systems

2013-01-18 Thread Éric Araujo

Éric Araujo added the comment:

I assume that ./script is working just like dir/script (what the tests exercize 
is not crystal clear to me).

--

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



[issue16957] shutil.which() shouldn't look in working directory on unix-y systems

2013-01-18 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Perhaps the comment in which() is misleading now, if I understand correctly the 
meaning of the words short circuit. Native speakers, please correct me if I 
wrong.

--

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



[issue16957] shutil.which() shouldn't look in working directory on unix-y systems

2013-01-18 Thread Thomas Kluyver

Thomas Kluyver added the comment:

Yes, as far as I know, ./script works in the same way as dir/script - from the 
current directory, but not from $PATH.

The first test added is for the case I reported - which('script') shouldn't 
look in the current directory on Unix. The second test would have failed 
without Serhiy's correction.

Serhiy, I agree that the comment wasn't quite right. I've uploaded a new 
version of the patch with a modified comment.

--
versions:  -Python 3.4
Added file: http://bugs.python.org/file28777/shutil_which_cwd3.patch

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



[issue16957] shutil.which() shouldn't look in working directory on unix-y systems

2013-01-17 Thread Thomas Kluyver

Thomas Kluyver added the comment:

I've added a patch with my suggested fix, as well as a test for this.

test_shutil all passes on Linux - I haven't run the tests on Windows.

--
keywords: +patch
Added file: http://bugs.python.org/file28761/shutil_which_cwd.patch

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



[issue16957] shutil.which() shouldn't look in working directory on unix-y systems

2013-01-17 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I think it should be

if os.path.dirname(cmd) and _access_check(cmd, mode):

--
nosy: +hynek, serhiy.storchaka, tarek

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



[issue16957] shutil.which() shouldn't look in working directory on unix-y systems

2013-01-17 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

No, it should be

if os.path.dirname(cmd):
if _access_check(cmd, mode):
return cmd
return None

--

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



[issue16957] shutil.which() shouldn't look in working directory on unix-y systems

2013-01-13 Thread Thomas Kluyver

New submission from Thomas Kluyver:

There's a 'short circuit' in shutil.which(), described as 'If we're given a 
full path which matches the mode and it exists, we're done here.'

It also matches if an executable file of the same name is present in the 
working directory, although on most Unix-y systems you need ./ to execute such 
files in a shell (i.e. ./foo, not just foo).

This could fool code calling which() into thinking that a program is installed, 
when it is not.

If we consider this a bug, one simple fix would be to only allow the short 
circuit with an absolute path, so the line

if _access_check(cmd, mode):

would become

if os.path.isabs(cmd) and _access_check(cmd, mode):

--
components: Library (Lib)
messages: 179897
nosy: takluyver
priority: normal
severity: normal
status: open
title: shutil.which() shouldn't look in working directory on unix-y systems
type: behavior
versions: Python 3.3

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