This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author WanderingLogic
Recipients WanderingLogic, akira, asvetlov, chris.jerdonek, christian.heimes, eric.araujo, eryksun, ezio.melotti, gregory.p.smith, lyapun, neologix, pitrou, r.david.murray, serhiy.storchaka
Date 2014-11-05.20:01:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1415217675.7.0.0765393995642.issue16353@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2014-11-05 20:01:15WanderingLogicsetrecipients: + WanderingLogic, gregory.p.smith, pitrou, christian.heimes, ezio.melotti, eric.araujo, r.david.murray, asvetlov, chris.jerdonek, neologix, akira, serhiy.storchaka, eryksun, lyapun
2014-11-05 20:01:15WanderingLogicsetmessageid: <1415217675.7.0.0765393995642.issue16353@psf.upfronthosting.co.za>
2014-11-05 20:01:15WanderingLogiclinkissue16353 messages
2014-11-05 20:01:14WanderingLogiccreate