[issue11095] subprocess popen broken for bytes and backslash

kai zhu report at bugs.python.org
Wed Feb 2 03:28:41 CET 2011


New submission from kai zhu <kaizhu at ugcs.caltech.edu>:

noticed when trying to call grep w/ backslashes in regexp, in shell mode.
same behavior on python2.5 & python3.2

in shell mode:
1. bytes is broken
2. 1st character after backslash is always silently truncated (with exception of '\\')

$ python3.2
Python 3.2rc1+ (py3k, Jan 24 2011, 15:00:02) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> subprocess.call(b'echo aa', shell = True) ## bytes broken
Traceback (most recent call last):
  File "<pseudosugar console>", line 1, in <module>
  File "/home/public/i486-pc-linux-gnu/lib/python3.2/subprocess.py", line 460, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/home/public/i486-pc-linux-gnu/lib/python3.2/subprocess.py", line 736, in __init__
    restore_signals, start_new_session)
  File "/home/public/i486-pc-linux-gnu/lib/python3.2/subprocess.py", line 1175, in _execute_child
    restore_signals, start_new_session, preexec_fn)
TypeError: Can't convert 'int' object to str implicitly
>>> subprocess.call('echo \aa', shell = True) ## backslash \
a
0
>>> subprocess.call('echo \\aa', shell = True) ## backslash \\
aa
0
>>> subprocess.call('echo \\\aa', shell = True) ## backslash \\\
a
0
>>> subprocess.call('echo \\\\aa', shell = True) ## backslash \\\\
a
0
>>> subprocess.call('echo \\\\\aa', shell = True) ## backslash \\\\\
\a
0
>>> subprocess.call('echo \\\\\\aa', shell = True) ## backslash \\\\\\
a
0
>>> subprocess.call('echo \\\\\\\\\\\\\\\\\\\\\\\\\aa', shell = True)
\\\a
0

----------
messages: 127714
nosy: kaizhu
priority: normal
severity: normal
status: open
title: subprocess popen broken for bytes and backslash
type: behavior
versions: Python 2.5, Python 3.2

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


More information about the Python-bugs-list mailing list