Matt Frank added the comment:

Unfortunately os.defpath seems to be hardcoded.  And hardcoded to the wrong 
value on every system I have looked at, including Linux.

Lib/posixpath.py sets defpath=':/bin:/usr/bin' which is _not_ what `getconf 
CS_PATH` returns on my Linux (the extra ':' at the beginning means "include the 
cwd"[1] which is almost certainly not what anyone wants.)  The hardcoded value 
'/bin:/usr/bin' would also be wrong for Solaris and AIX installations that are 
trying to be POSIX (I think they use /usr/xpg4/bin/sh).

Meanwhile Lib/macpath.py sets defpath=':', which is also almost certainly 
wrong.  (I don't have a Mac and have never programmed one, but StackOverflow[2] 
indicates that one should use `path_helper` (which in turn gets the default 
value by reading it from the files in /etc/paths.d))[3]  So it seems likely 
that this patch breaks Popen() on MacOS (unless, perhaps, a path of ':' means 
something special on Mac?).

And Lib/ntpath.py sets defpath='.;C:\\bin', which doesn't resemble a path that 
even works (as pointed out in now closed http://bugs.python.org/issue5717).  
(The correct value may be 
'%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\'.)

So I don't know where to go next.  I'm happy to cook up a different patch, but 
I have no idea what it should be.  Here are some possibilities:

1. Kick the can down the road: file a new bug against os.defpath and (somehow) 
fix Lib/*path.py so they do something more reasonable in more cases.  One of 
which might be to have posixpath.py try to call os.confstr() (and then, 
perhaps, special-code something in Modules/posixmodule.c in the case that 
HAVE_CONFSTR is not defined.)

2. Modify @akira's patch to call os.confstr('CS_PATH') instead of os.defpath, 
and then deal with the fact that very few systems actually implement confstr() 
(perhaps by special-coding something in Modules/posixmodule.c as described 
above.)

3. Modify this patch to fall back to `PATH` if `sh` can't be found on 
os.defpath (or os.confstr('CS_PATH') fails).



[1] `man bash` on Linux, search for the description of the PATH variable.  
(e.g., http://man7.org/linux/man-pages/man1/bash.1.html)
[2] 
http://stackoverflow.com/questions/9832770/where-is-the-default-terminal-path-located-on-mac
[3] 
https://developer.apple.com/library/mac/documentation/Darwin/Reference/Manpages/man8/path_helper.8.html
[4] 
http://superuser.com/questions/124239/what-is-the-default-path-environment-variable-setting-on-fresh-install-of-window

----------

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

Reply via email to