Message60506
Logged In: YES
user_id=1054957
I have found a very simple patch.
First I have implemented this function:
import os
def isrealfile(file):
"""
Test if file is on the os filesystem
"""
if not hasattr(file, 'fileno'): return False
try: tmp = os.dup(file.fileno())
except: return False
else: os.close(tmp); return True
Microsoft implementation of stdout/err/in when no console is
created (and when no pipes are used) actually are not 'real'
files.
Then I have added the following code in sitecustomize.py:
import sys
class NullStream:
"""
A file like class that writes nothing
"""
def close(self): pass
def flush(self): pass
def write(self, str): pass
def writelines(self, sequence): pass
if not isrealfile(sys.__stdout__):
sys.stdout = NullStream()
if not isrealfile(sys.__stderr__):
sys.stderr = NullStream()
I have tested the code only on Windows XP Pro.
P.S.
isrealfile could be added in os module.
Regards Manlio Perillo |
|
Date |
User |
Action |
Args |
2008-01-20 09:56:57 | admin | link | issue973507 messages |
2008-01-20 09:56:57 | admin | create | |
|