Use `open` to open file descriptors in place of `file`

Reason: there is no `file()` in Python 3.

Fix was originally presented by @kovidgoyal in [3deb69][1], but I cannot
cherry-pick this commit, because its commit message is highly undescriptive.

Fixes #1008

[1]: 3deb6988c8
This commit is contained in:
ZyX 2014-08-23 03:55:37 +04:00
parent 6e128c14ba
commit 74d147a0be
1 changed files with 3 additions and 3 deletions

View File

@ -274,9 +274,9 @@ def daemonize(stdin=os.devnull, stdout=os.devnull, stderr=os.devnull):
sys.exit(1)
# Redirect standard file descriptors.
si = file(stdin, 'r')
so = file(stdout, 'a+')
se = file(stderr, 'a+', 0)
si = open(stdin, 'rb')
so = open(stdout, 'a+b')
se = open(stderr, 'a+b', 0)
os.dup2(si.fileno(), sys.stdin.fileno())
os.dup2(so.fileno(), sys.stdout.fileno())
os.dup2(se.fileno(), sys.stderr.fileno())