Issue1723

classification
Title: stdout not working; print redirected to stderr?
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.5
process
Status: open Resolution: remind
Dependencies: Superseder:
Assigned To: Nosy List: amak, fwierzbicki, jasonsmith, pjenvey
Priority: low Keywords: console

Created on 2011-03-23.20:33:59 by jasonsmith, last changed 2013-02-25.22:03:01 by amak.

Messages
msg6451 (view) Author: Jason Smith (jasonsmith) Date: 2011-03-23.20:33:59
From interactive mode:
>>> import sys
>>> sys.stdout.write("Hello.")
>>> sys.stderr.write("Hello.")
Hello.>>>

The first write should print 'Hello.' to console, but prints nothing.

I also noticed it looks like the print command is printing to stderr, not to stdout (at least it looks like this from another program I have with colored output).
msg6452 (view) Author: Jason Smith (jasonsmith) Date: 2011-03-23.20:36:15
This bug should be against 2.5.2 final.  I don't see it in the list.  On Ubuntu 10.10.
msg6453 (view) Author: Jason Smith (jasonsmith) Date: 2011-03-23.20:58:06
The behavior is as expected when using the -u flag.
msg6454 (view) Author: Jason Smith (jasonsmith) Date: 2011-03-23.22:16:52
It works if you follow the command by sys.stdout.flush().  The difference between Python and Jython behavior appears to be autoflush.
msg6456 (view) Author: Philip Jenvey (pjenvey) Date: 2011-03-24.20:51:44
IIRC our problem is our JLine console reader doesn't actually output everything (like the >>> prompt) via sys.stdout. If you disable it and use the bare minimum console I believe we'd match CPython's behavior

So on CPython you're seeing autoflush like behavior because the prompt is immediately printed afterwards and a flush is done to ensure the prompt shows up

Otherwise you'd see similar behavior in cpython if you did:

>>> sys.stdout.write('hello'); time.sleep(2)

Anyway I see this as a very minor implementation detail, but it would be nice to fix this at some point. Though it may be problematic to fix (see #695383 for a somewhat related problem)
History
Date User Action Args
2013-02-25 22:03:01amaksetkeywords: + console
nosy: + amak
2013-02-20 00:08:55fwierzbickisetnosy: + fwierzbicki
resolution: remind
versions: + Jython 2.5, - 2.5.2rc
2011-03-24 20:51:45pjenveysetpriority: low
nosy: + pjenvey
messages: + msg6456
components: + Core, - Any
2011-03-23 22:16:52jasonsmithsetmessages: + msg6454
2011-03-23 20:58:06jasonsmithsetmessages: + msg6453
2011-03-23 20:36:15jasonsmithsetmessages: + msg6452
2011-03-23 20:33:59jasonsmithcreate