Issue695383
Created on 2003-03-01.00:27:00 by daishiharada, last changed 2008-06-10.23:29:31 by pjenvey.
| msg821 (view) |
Author: daishi harada (daishiharada) |
Date: 2003-03-01.00:27:00 |
|
The behavior that I'm seeing is:
% jython
Jython 2.1+ on java1.3.1_02 (JIT: null)
Type "copyright", "credits" or "license" for more
information.
>>> import sys
>>> sys.stdout.close()
Traceback (innermost last):
(no code object) at line 0
ValueError: I/O operation on closed file
%
On the other hand, under CPython:
% python
Python 2.2 (#1, Feb 26 2002, 15:49:15)
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-81)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> import sys
>>> sys.stdin.close()
>>>
I understand raising ValueError, but I can't seem to
even catch
the exception.
|
| msg3252 (view) |
Author: Philip Jenvey (pjenvey) |
Date: 2008-06-08.04:40:46 |
|
trunk works like CPython now in this regard:
Jython 2.3a0+ (trunk:4553:4564M, Jun 7 2008, 21:19:17)
[Java HotSpot(TM) Client VM (Apple Inc.)] on java1.5.0_13
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.stdout.close()
>>> print 'hi'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: I/O operation on closed file
>>> print 'hi'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: I/O operation on closed file
>>> try:
... print 'hi'
... except ValueError:
... print >> sys.stderr, 'hi'
...
hi
>>>
(and note the ValueError didn't occur until I tried printing something)
|
| msg3272 (view) |
Author: Philip Jenvey (pjenvey) |
Date: 2008-06-10.23:29:30 |
|
it looks like we end up exiting because we actually write our prompt
'>>>' to sys.stdout. So writing to the closed stdout raises a
ValueError, breaking us out of the interactive prompt loop (causing the
exit)
We should actually be writing the prompt to stderr -- that will totally
avoid the exception.
The problem with that is when readline is enabled, the only way we can
write the prompt to stderr instead of stdout is by doing it ourselves
(right now Readline.readline() writes the prompt for us).
This seems to break readline in some situations: for example, when
recalling a previous line in the history (with the up arrow), readline
for some reason doesn't realize there's a prompt at the beginning of the
line and allows you to muck with those characters
|
| msg3271 (view) |
Author: Philip Jenvey (pjenvey) |
Date: 2008-06-10.23:05:44 |
|
my mistake, we're ok when sys.stdin is closed, but we still quit when
sys.stdout is closed
|
|
| Date |
User |
Action |
Args |
| 2008-06-10 23:29:31 | pjenvey | set | messages:
+ msg3272 |
| 2008-06-10 23:05:45 | pjenvey | set | status: closed -> open resolution: fixed -> accepted messages:
+ msg3271 |
| 2008-06-08 04:40:51 | pjenvey | set | status: open -> closed resolution: fixed messages:
+ msg3252 nosy:
+ pjenvey |
| 2003-03-01 00:27:00 | daishiharada | create | |
|