[issue17012] Differences between /usr/bin/which and shutil.which()

2013-04-16 Thread Roundup Robot

Roundup Robot added the comment:

New changeset eb8c575fa781 by Barry Warsaw in branch '3.3':
- Issue #17012: shutil.which() no longer fallbacks to the PATH environment
http://hg.python.org/cpython/rev/eb8c575fa781

New changeset 8f5b37f8f964 by Barry Warsaw in branch 'default':
- Issue #17012: shutil.which() no longer fallbacks to the PATH environment
http://hg.python.org/cpython/rev/8f5b37f8f964

--
nosy: +python-dev

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



[issue17012] Differences between /usr/bin/which and shutil.which()

2013-04-16 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

I couldn't wait. :)

--
assignee: serhiy.storchaka - barry

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



[issue17012] Differences between /usr/bin/which and shutil.which()

2013-04-16 Thread Barry A. Warsaw

Changes by Barry A. Warsaw ba...@python.org:


--
resolution:  - fixed
status: open - closed

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



[issue17012] Differences between /usr/bin/which and shutil.which()

2013-04-15 Thread Barry A. Warsaw

Changes by Barry A. Warsaw ba...@python.org:


--
nosy: +barry

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



[issue17012] Differences between /usr/bin/which and shutil.which()

2013-04-15 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

From a documentation standpoint, path='' is not the same as When no path is 
specified, so indeed it should return None when path=''.  Serhiy's patch 
looks good to me.

--

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



[issue17012] Differences between /usr/bin/which and shutil.which()

2013-04-15 Thread Barry A. Warsaw

Changes by Barry A. Warsaw ba...@python.org:


--
assignee:  - barry

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



[issue17012] Differences between /usr/bin/which and shutil.which()

2013-04-15 Thread Barry A. Warsaw

Changes by Barry A. Warsaw ba...@python.org:


--
assignee: barry - serhiy.storchaka

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



[issue17012] Differences between /usr/bin/which and shutil.which()

2013-04-15 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

Serhiy, I'd say go ahead and commit it.  +1 from me.

--

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



[issue17012] Differences between /usr/bin/which and shutil.which()

2013-02-18 Thread Ned Deily

Ned Deily added the comment:

The result of PATH= is also platform dependent. Testing on OS X which has a BSD 
heritage rather a Linux one:

$ PATH= /usr/bin/which python
./python

# without patch
$ PATH= ./python -c 'import shutil; print(shutil.which(python))'
python
$ ./python -c 'import shutil; print(shutil.which(python, path=))'
/usr/bin/python

# with the patch:
$ PATH= ./python -c 'import shutil; print(shutil.which(python))'
None
$ ./python -c 'import shutil; print(shutil.which(python, path=))'
None

So, for OS X, shutil.which doesn't match /usr/bin/which behavior for the PATH= 
case either with or without the patch.  FreeBSD (8.2) /usr/bin/which is the 
same.  The other cases are the same as Linux.

I suppose the patched behavior is preferable, though.

In any case, the shutil.which docs also need to be updated.

--

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



[issue17012] Differences between /usr/bin/which and shutil.which()

2013-02-17 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Ping.

--

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



[issue17012] Differences between /usr/bin/which and shutil.which()

2013-01-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you, Ned, for information.

Here is a patch which remove the first difference (processing an empty path).

The second difference is not semantically significant and I'm not sure whether 
we need to get rid of it.

--
keywords: +patch
Added file: http://bugs.python.org/file28807/shutil_which_empty_path.patch

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



[issue17012] Differences between /usr/bin/which and shutil.which()

2013-01-23 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
stage:  - patch review

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



[issue17012] Differences between /usr/bin/which and shutil.which()

2013-01-22 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

$ PATH= /usr/bin/which python
$ PATH=: /usr/bin/which python
./python
$ PATH=/usr: /usr/bin/which python
./python

 shutil.which('python', path='')
'/usr/bin/python'
 shutil.which('python', path=':')
'python'
 shutil.which('python', path='/usr:')
'python'

First, I propose interpret path='' as an empty path, not as a default path (we 
have None for this). However the interpreting of an empty directory in 
non-empty PATH can be platform-depending.

--
components: Library (Lib)
messages: 180376
nosy: brian.curtin, hynek, pitrou, serhiy.storchaka, tarek
priority: normal
severity: normal
status: open
title: Differences between /usr/bin/which and shutil.which()
type: behavior
versions: Python 3.3, Python 3.4

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



[issue17012] Differences between /usr/bin/which and shutil.which()

2013-01-22 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I'm not sure reproducing the quirks of /usr/bin/which is a good idea. 
shutil.which() is meant to be useful and easy to understand, not to be 100% 
bash-compatible.
And, anyway, what would be the point of passing an empty path, if the return 
value is guaranteed to be None?

--

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



[issue17012] Differences between /usr/bin/which and shutil.which()

2013-01-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

/usr/bin/which is not a Bash. ;)

The path can be unexpectedly empty. If we got None then we can detect the 
error, but if we got something out of the path then we can miss our fault.

--

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



[issue17012] Differences between /usr/bin/which and shutil.which()

2013-01-22 Thread R. David Murray

R. David Murray added the comment:

What I think it is suppose to do (the user expects it to do) is find the 
program that would be run if the command were typed at the command prompt.

rdmurray@hey:~which python
/usr/bin/python
rdmurray@hey:~export PATH=
rdmurray@hey:~which python
python not found
rdmurray@hey:~python
zsh: command not found: python

As Serhiy noted, this result may be platform dependent.  Which is unfortunate.

--
nosy: +r.david.murray

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



[issue17012] Differences between /usr/bin/which and shutil.which()

2013-01-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

No, I noted that result of PATH=: or PATH=$PATH: can be platform dependent (I'm 
not sure).

--

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



[issue17012] Differences between /usr/bin/which and shutil.which()

2013-01-22 Thread R. David Murray

R. David Murray added the comment:

I was speaking in general of 'which program would be executed if the command is 
typed at the prompt' as being system dependent, which it demonstrably is since 
the behavior on unix and windows differs with regards to the current directory.

--

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



[issue17012] Differences between /usr/bin/which and shutil.which()

2013-01-22 Thread R. David Murray

R. David Murray added the comment:

And no, what I wrote wasn't clear :)

--

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



[issue17012] Differences between /usr/bin/which and shutil.which()

2013-01-22 Thread Ned Deily

Ned Deily added the comment:

FWIW, the POSIX standard gives some guidance on how PATH is to be interpreted 
for conforming systems, including:

A zero-length prefix is a legacy feature that indicates the current working 
directory. It appears as two adjacent colon characters ( :: ), as an 
initial colon preceding the rest of the list, or as a trailing colon 
following the rest of the list. A strictly conforming application shall use an 
actual pathname (such as .) to represent the current working directory in PATH.

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html

--
nosy: +ned.deily

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