Title: ignores interpreter.setOut()
Type: behaviour Severity: normal
Components: Library Versions: 2.5.1
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: pjenvey, steveims, zyasoft
Priority: Keywords:

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; 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 without stdout; 

Output written to the output stream (as expected):
os received:  [from print; 
from sys.stdout; from 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 org.python.util.PythonInterpreter;

public class JythonTest {
  public static void main(String[] argv) {
    PythonInterpreter interp = new PythonInterpreter();
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    System.out.println("Output written directly to stdout (problem:  bypassed the specified output stream):");
    System.out.println("Output written to the output stream (as expected):");
    System.out.println("os received:  [" + os.toString() + "]");

And here's

import subprocess
import sys

print "from print; "
sys.stdout.write("from sys.stdout; ")
sys.stdout.flush()["echo", "from without stdout; "])["echo", "from 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:50zyasoftsetstatus: open -> closed
resolution: wont fix
messages: + msg5943
nosy: + zyasoft
2010-04-04 18:22:42pjenveysetnosy: + pjenvey
messages: + msg5627
2010-03-05 05:05:04steveimssettype: behaviour
messages: + msg5562
2010-03-05 04:52:49steveimscreate