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.

Title: os.popen w/o using the shell
Type: enhancement Stage:
Components: Library (Lib) Versions:
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: astrand, ianbicking, julian69, loewis, nnorwitz
Priority: normal Keywords:

Created on 2002-04-25 15:30 by ianbicking, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Messages (7)
msg10518 - (view) Author: Ian Bicking (ianbicking) * Date: 2002-04-25 15:30
I heard that there was an undocumented feature to the
os.popen family, where instead of passing a command
string as the first argument you could pass a list, as
[path, arg1, arg2, ...], and circumvent any shell
interpretation.  I was disapointed to see that this was
not so ("popen() argument 1 must be string, not list"
ditto tuple)

I believe this would be an excellent feature -- using
the shell is a significant source of errors due to
quoting, as well as a serious security concern.  95% of
the time the shell is not required.  The shell also
introduces portability concerns (e.g., bug #512433) --
creating a Python shell is not necessary when the shell
is usually superfluous anyway.

msg10519 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-04-25 18:13
Logged In: YES 

This feature is indeed available in popen2.
msg10520 - (view) Author: Ian Bicking (ianbicking) * Date: 2002-04-25 18:18
Logged In: YES 

I see you are correct.  It would be nice if this feature was
consistent across all popen*, and was also documented (and
so  also committed to with clear semantics)
msg10521 - (view) Author: Julián Muñoz (julian69) Date: 2003-01-08 16:15
Logged In: YES 

Does this mean that giving a list to popen2 free us from
taking care of the dangerous characters that could be
interprated/escaped by the shell ???

I don't find any documentation about this feature !!!

msg10522 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2003-11-01 16:29
Logged In: YES 

popen5 never uses the shell
msg10523 - (view) Author: Ian Bicking (ianbicking) * Date: 2005-04-19 16:45
Logged In: YES 

This may not matter enough to resolve now, with the advent
of the subprocess module.
msg10524 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2006-11-21 08:15
I agree this isn't required in popen since you can do it with the subprocess module.  Closing.
Date User Action Args
2022-04-10 16:05:16adminsetgithub: 36496
2002-04-25 15:30:02ianbickingcreate