Skip to content

Commit 2c0c04e

Browse files
committed
Fix roundup-server logging for Python 3.
Using the roundup-server support for redirecting output to a log file fails with Python 3: sys.stdout = sys.stderr = open(self["LOGFILE"], 'a', 0) ValueError: can't have unbuffered text I/O Thus, this patch switches that redirection to use line-buffered output (1 as third argument to open), which works with both Python 2 and Python 3.
1 parent 406a29b commit 2c0c04e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

roundup/scripts/roundup_server.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,9 @@ def trackers(self):
674674

675675
def set_logging(self):
676676
"""Initialise logging to the configured file, if any."""
677-
# appending, unbuffered
678-
sys.stdout = sys.stderr = open(self["LOGFILE"], 'a', 0)
677+
# appending, line-buffered (Python 3 does not allow unbuffered
678+
# text files)
679+
sys.stdout = sys.stderr = open(self["LOGFILE"], 'a', 1)
679680

680681
def get_server(self):
681682
"""Return HTTP server object to run"""

0 commit comments

Comments
 (0)