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 <>
Unfortunately os.defpath seems to be hardcoded.  And hardcoded to the wrong value on every system I have looked at, including Linux.

Lib/ 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/ 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/ sets defpath='.;C:\\bin', which doesn't resemble a path that even works (as pointed out in now closed  (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/* so they do something more reasonable in more cases.  One of which might be to have 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.,
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: <>
2014-11-05 20:01:15WanderingLogiclinkissue16353 messages
2014-11-05 20:01:14WanderingLogiccreate