[issue20344] subprocess.check_output() docs misrepresent what shell=True does

2014-03-27 Thread Tobias Klausmann

Tobias Klausmann added the comment:

Hi! 

On Tue, 25 Mar 2014, Tuomas Savolainen wrote:
 Created a patch that adds notice of using shell=True and iterable to the 
 documentation. Please do comment if the formatting is wrong (this my first 
 documentation patch).

I'd use articles, i.e. and a list and does not raise an error 

Also, s/except/expect/

Regards,
Tobias

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20344
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20344] subprocess.check_output() docs misrepresent what shell=True does

2014-01-22 Thread Tobias Klausmann

New submission from Tobias Klausmann:

The subprocess docs state that the first argument can be either a string or an 
iterable that contains the program and arguments to run. It also points out 
that using shell=True allows for shell constructs. It does not mention a 
subtlety that is introduced by Python's use of sh -c (on Unix):

Using a string that contains the full command line with args and shell=False 
breaks as expected:

 subprocess.check_output(ls foo, shell=False)
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/lib64/python3.3/subprocess.py, line 576, in check_output
with Popen(*popenargs, stdout=PIPE, **kwargs) as process:
  File /usr/lib64/python3.3/subprocess.py, line 824, in __init__
restore_signals, start_new_session)
  File /usr/lib64/python3.3/subprocess.py, line 1448, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'ls foo'

Using shell=True instead works as expected (since foo does not exist, ls exits 
with non-0 and a different Exception is raised. This, too is to spec and 
exactly what the docs describe.

 subprocess.check_output(ls foo, shell=True)
ls: cannot access foo: No such file or directory
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/lib64/python3.3/subprocess.py, line 589, in check_output
raise CalledProcessError(retcode, process.args, output=output)
subprocess.CalledProcessError: Command 'ls foo' returned non-zero exit status 2

Using shell=False and making the command a list of command and args does the 
same thing:

 subprocess.check_output([ls, foo], shell=False)
ls: cannot access foo: No such file or directory
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/lib64/python3.3/subprocess.py, line 589, in check_output
raise CalledProcessError(retcode, process.args, output=output)
subprocess.CalledProcessError: Command '['ls', 'foo']' returned non-zero exit 
status 2

But using an iterable _and_ requesting a shell results in something very broken:

 subprocess.check_output([ls, foo], shell=True)
[contents of my homedir are returned]


Note that the argument foo completely disappears, apparently. strace() 
reveals that foo is never added to the call to ls. Instead, it becomes $0 
in the shell that ls runs in. This is exactly to spec (i.e. bash is not 
broken). bash -c foo bar baz will start a shell that sets $0 to bar, $1 to 
baz and then executes foo. Whereas bash -c 'foo bar baz' will run 'foo 
bar baz'.

I think there are three possible fixes here:
1- Make check_output(list, shell=True) run something like bash -c '%s' %  
.join(list)
2- Change the docs to warn of the unintended consequences of combining lists 
with shell=True
3- Make check_output() throw an Exception if the first argument is a list and 
shell=True

The first option would make it easiest for people to just use it, but I fear 
the string manipulation may become the source of bugs with security 
implications in the future.

The second option keeps the status quo, but people tend to not read docs, so it 
may not be as effective as one would like, especially since shell-True already 
has warnings and people tend to go yeah I know about unverified input, but 
it's not a problem for me and then ignore both warnings.

Option 3 has the disadvantage that existing scripts that _expect_ the behavior 
may break.

--
assignee: docs@python
components: Documentation, Library (Lib)
messages: 208811
nosy: docs@python, klausman
priority: normal
severity: normal
status: open
title: subprocess.check_output() docs misrepresent what shell=True does
type: behavior
versions: Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20344
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10570] curses.tigetstr() returns bytes, but curses.tparm() expects a string

2011-08-05 Thread Tobias Klausmann

Tobias Klausmann klaus...@gentoo.org added the comment:

This bug is still not fixed and basically makes the curses module unusable 
except for very narrow use cases. Unfortunately, my C-fu is very weak, 
otherwise I'd try to make a patch.

--
nosy: +klausman

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10570
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9447] Python 3.1.2 test suite segfaults on the alpha architecture

2010-08-01 Thread Tobias Klausmann

New submission from Tobias Klausmann klaus...@gentoo.org:

During testing for inclusion in the Gentoo distribution, we ran into a test 
failure (actually a SEGV) when running the test suite on the alpha architecture.

Log of test failure and backtrace in gdb is here:
http://dev.gentoo.org/~klausman/python-3.1.2-testrun.log
and also attached to this bug report.


gcc is 4.4.3
glibc is 2.11.2
Kernel is 2.6.33

If more info or access to an alpha machine is needed, feel free to contact me 
or the alpha arch team at gentoo (al...@gentoo.org)

--
components: Tests
files: python-3.1.2-testrun.log
messages: 112319
nosy: klausman
priority: normal
severity: normal
status: open
title: Python 3.1.2 test suite segfaults on the alpha architecture
type: crash
versions: Python 3.2
Added file: http://bugs.python.org/file18308/python-3.1.2-testrun.log

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9447
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9447] Python 3.1.2 test suite segfaults on the alpha architecture

2010-08-01 Thread Tobias Klausmann

Tobias Klausmann klaus...@gentoo.org added the comment:

Nevermind, we messed this up ourselves. Sorry for the noise.

--
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9447
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com