[ python-Bugs-973507 ] sys.stdout problems with pythonw.exe
SourceForge.net
noreply at sourceforge.net
Tue Jun 15 16:34:41 EDT 2004
Bugs item #973507, was opened at 2004-06-15 20:34
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=973507&group_id=5470
Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Manlio Perillo (manlioperillo)
Assigned to: Nobody/Anonymous (nobody)
Summary: sys.stdout problems with pythonw.exe
Initial Comment:
>>> sys.version
'2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit
(Intel)]'
>>> sys.platform
'win32'
>>> sys.getwindowsversion()
(5, 1, 2600, 2, '')
Hi.
I have written this script for reproducing the bug:
import sys
class teeIO:
def __init__(self, *files):
self.__files = files
def write(self, str):
for i in self.__files:
print >> trace, 'writing on %s: %s' % (i, str)
i.write(str)
print >> trace, '-' * 70
def tee(*files):
return teeIO(*files)
log = file('log.txt', 'w')
err = file('err.txt', 'w')
trace = file('trace.txt', 'w')
sys.stdout = tee(log, sys.__stdout__)
sys.stderr = tee(err, sys.__stderr__)
def write(n, width):
sys.stdout.write('x' * width)
if n == 1: return
write(n - 1, width)
try:
1/0
except:
write(1, 4096)
[output from err.log]
Traceback (most recent call last):
File "sys.py", line 36, in ?
write(1, 4096)
File "sys.py", line 28, in write
sys.stdout.write('x' * width)
File "sys.py", line 10, in write
i.write(str)
IOError: [Errno 9] Bad file descriptor
TeeIO is needed for actually read the program output,
but I don't know if the problem is due to teeIO.
The same problem is present for stderr, as can be seen
by swapping sys.__stdout__ and sys.__stderr__.
As I can see, 4096 is the buffer size for sys.stdout/err.
The problem is the same if the data is written in
chunks, ad example: write(2, 4096/2).
The bug isn't present if I use python.exe or if I write
less than 4096 bytes.
Thanks and regards Manlio Perillo
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=973507&group_id=5470
More information about the Python-bugs-list
mailing list