Fix crash when --daemon is given (Python 3).

This commit is contained in:
Valentin Lorentz 2013-06-29 13:58:41 +02:00
parent dce3c97fe4
commit 46b89cfc0e
2 changed files with 5 additions and 2 deletions

View File

@ -44,6 +44,7 @@ import shutil
import signal
if sys.version_info[0] < 3:
import cStringIO as StringIO
StringIO = StringIO.StringIO
else:
from io import StringIO
@ -273,8 +274,8 @@ if __name__ == '__main__':
# level WARNING on upkeep.
sys.stdout.close()
sys.stderr.close()
sys.stdout = StringIO.StringIO()
sys.stderr = StringIO.StringIO()
sys.stdout = StringIO()
sys.stderr = StringIO()
# We have to be really methodical here.
os.close(0)
os.close(1)

View File

@ -149,6 +149,8 @@ def upkeep():
except IOError: # Win98 sux0rs!
pass
if conf.daemonized:
if sys.version_info[0] >= 3:
from io import TextIOWrapper as file
# If we're daemonized, sys.stdout has been replaced with a StringIO
# object, so let's see if anything's been printed, and if so, let's
# log.warning it (things shouldn't be printed, and we're more likely