Issue1735774
Created on 2007-06-12.14:12:57 by pekka.klarck, last changed 2007-09-24.06:26:32 by pjenvey.
File name |
Uploaded |
Description |
Edit |
Remove |
os_popen.patch
|
pekka.klarck,
2007-07-24.23:05:23
|
|
|
|
msg1628 (view) |
Author: Pekka Klärck (pekka.klarck) |
Date: 2007-06-12.14:12:57 |
|
If command given to os.popen is unicode redirecting stderr to stdout (2>&1) or either stdout or stderr to a file (>out.txt or 2>err.txt) fails. What happens is that the part that should take care of redirecting is given to the command as an argument and not stripped by the operating system.
As the example below demonstrates everything works ok if the command is a normal string. I also tested this with CPython 2.5 and there unicode was not a problem. Haven't tested using any other popen variant.
Jython 2.2b2 on java1.5.0_11
Type "copyright", "credits" or "license" for more informati
>>> import os
>>> for cmd in [ 'echo foo', 'echo foo 2>&1' ]:
... p = os.popen(cmd)
... print 'str:', p.read()
... p.close()
... p = os.popen(unicode(cmd))
... print 'uni:', p.read()
... p.close()
...
str: foo
uni: foo
str: foo
uni: foo 2>&1
|
msg1629 (view) |
Author: Pekka Klärck (pekka.klarck) |
Date: 2007-07-24.23:05:23 |
|
This problem can be pretty nasty because when it occurs it can be really hard to debug. At least it was for me...
Luckily the fix for this problem is trivial -- changing testing against types.StringType to types.StringTypes in javashell.py. I've created and attached a patch including the fix and two new unit tests to test_javashell.py.
File Added: os_popen.patch
|
msg1630 (view) |
Author: Philip Jenvey (pjenvey) |
Date: 2007-09-24.06:26:32 |
|
applied in r3524/3526
I used basestring instead of types.StringTypes
thanks!
|
|
Date |
User |
Action |
Args |
2007-06-12 14:12:57 | pekka.klarck | create | |
|