| |
31 |
# Implement workaround for prints in non-console mode. In non-console mode
|
| |
32 |
# (with "pythonw"), print randomically fails with "[errno 9] Bad file descriptor"
|
| |
33 |
# when the printed text is flushed (eg: buffer full); this is because the
|
| |
34 |
# sys.stdout object is bound to an invalid file descriptor.
|
| |
35 |
# Python 3000 has a fix for it (http://bugs.python.org/issue1415), but we
|
| |
36 |
# feel that a workaround in PyInstaller is a good thing since most people
|
| |
37 |
# found this problem for the first time with PyInstaller as they don't
|
| |
38 |
# usually run their code with "pythonw" (and it's hard to debug anyway).
|
| |
39 |
class NullWriter:
|
| |
40 |
def write(*args): pass
|
| |
41 |
def flush(*args): pass
|
| |
42 |
if sys.stdout.fileno() < 0:
|
| |
43 |
sys.stdout = NullWriter()
|
| |
44 |
if sys.stderr.fileno() < 0:
|
| |
45 |
sys.stderr = NullWriter()
|