[issue9265] Incorrect name passed as arg[0] when shell=True and executable specified

R. David Murray report at bugs.python.org
Mon Jul 19 15:27:06 CEST 2010


R. David Murray <rdmurray at bitdance.com> added the comment:

Stefan: patch looks good to me in principle, but it looks like you made it against 2.7, and we commit to py3k first now.  The test does not work correctly on py3k because of a bytes/string issue, but I'm not clear on why the problem happens (I haven't looked in to it, I just observe that the test fails).  And yes I think this should go into 2.6 and 3.1 as well.

Narnie: if only we had enough manpower to handle all bugs as rapidly.  Please keep learning and help us where you can :)

As for your test...I'm not clear if you are saying Stefan's patch fixes or problem or not, but please observe this:

>>> os.execv('/bin/bash', ['/bin/sh', 'echos', 'foo'])
/bin/sh: echos: No such file or directory

That is, it is /bin/bash that is running, but it thinks its name is '/bin/sh' because that is what we passed in arg0 in the execv call.
Similarly you could do:

>>> os.execv('/bin/bash', ['my_funny_walk', 'echos', 'foo'])
my_funny_walk: echos: No such file or directory

So, popen is *calling* the correct shell, it's just that it is giving it the wrong arg[0] name, which Stefan's patch fixes.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9265>
_______________________________________


More information about the Python-bugs-list mailing list