[issue7839] Popen should raise ValueError if pass a string when shell=False or a list when shell=True

Eric Smith report at bugs.python.org
Wed Jun 9 02:15:37 CEST 2010


Eric Smith <eric at trueblade.com> added the comment:

I agree with David. For the issue raised here, at most I would make (list, shell=True) and (str, shell=False) raise errors.

There's an issue (that I can't find right now) for creating functions that convert from str->list and list->str for cases such as this. shlex is sort of str->list, but it has issues on Windows. I've mentioned elsewhere that for Windows list->str is not always possible, because there is no standard for the corresponding str->list that each program is responsible for.

On Unix-like systems, when the called programs are run they get a pre-parsed list (argv). This list is created by the caller, either directly or through a shell. When a shell is doing this, at least the behavior is somewhat standard.

On Windows, the called programs get a string, and they're in charge of parsing it, if they want to. Many programs use the C library to create argv, but exactly how that parsing works changes between runtime vendors and over time within a vendor. There's no solution that will work in all cases.

Which is not to suggest that we shouldn't try, just that it will be hard.

----------

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


More information about the Python-bugs-list mailing list