Issue1569
Created on 2010-03-05.04:52:48 by steveims, last changed 2010-08-06.05:48:50 by zyasoft.
msg5561 (view) |
Author: Steve Ims (steveims) |
Date: 2010-03-05.04:52:48 |
|
This is an embedded scenario.
I've set the output stream for the interpreter: print and sys.stdout.write behave as expected; subprocess.call() does not.
Example code shown in the attached files.
Results of running the example are shown below. I expected all of the output to be written to the output stream specified to the interpreter, but that wasn't the case.
Output written directly to stdout (problem: bypassed the specified output stream):
===================================================================================
from subprocess.call without stdout;
Output written to the output stream (as expected):
==================================================
os received: [from print;
from sys.stdout; from subprocess.call with stdout;
]
|
msg5562 (view) |
Author: Steve Ims (steveims) |
Date: 2010-03-05.05:05:04 |
|
Appears I cannot upload files, so I'll copy the example here.
First, the .java which embeds Jython:
.....................................
package simple;
import java.io.ByteArrayOutputStream;
import org.python.util.PythonInterpreter;
public class JythonTest {
public static void main(String[] argv) {
PythonInterpreter interp = new PythonInterpreter();
ByteArrayOutputStream os = new ByteArrayOutputStream();
interp.setOut(os);
System.out.println("Output written directly to stdout (problem: bypassed the specified output stream):");
System.out.println("===================================================================================");
interp.execfile("test.py");
System.out.println("");
System.out.println("Output written to the output stream (as expected):");
System.out.println("==================================================");
System.out.println("os received: [" + os.toString() + "]");
}
}
And here's test.py:
...................
import subprocess
import sys
print "from print; "
sys.stdout.write("from sys.stdout; ")
sys.stdout.flush()
subprocess.call(["echo", "from subprocess.call without stdout; "])
subprocess.call(["echo", "from subprocess.call with stdout; "], stdout=sys.stdout)
|
msg5627 (view) |
Author: Philip Jenvey (pjenvey) |
Date: 2010-04-04.18:22:42 |
|
I don't think subprocess in an embedded CPython interpreter works like this either
|
msg5943 (view) |
Author: Jim Baker (zyasoft) |
Date: 2010-08-06.05:48:49 |
|
subprocess has separate settings from the interpreter, and as Phil points out, we alredy have the same behavior as CPython
|
|
Date |
User |
Action |
Args |
2010-08-06 05:48:50 | zyasoft | set | status: open -> closed resolution: wont fix messages:
+ msg5943 nosy:
+ zyasoft |
2010-04-04 18:22:42 | pjenvey | set | nosy:
+ pjenvey messages:
+ msg5627 |
2010-03-05 05:05:04 | steveims | set | type: behaviour messages:
+ msg5562 |
2010-03-05 04:52:49 | steveims | create | |
|