py3: All tests in srv module now pass

This commit is contained in:
Kovid Goyal 2019-04-15 14:34:16 +05:30
parent 0f4e37dfca
commit 976a3f9b4a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -22,6 +22,7 @@ from calibre.utils.shared_file import share_open, raise_winerror
from polyglot.builtins import iteritems, map, range
from polyglot import reprlib
from polyglot.http_cookie import SimpleCookie
from polyglot.builtins import unicode_type
from polyglot.urllib import parse_qs, quote as urlquote
from polyglot.binary import as_hex_unicode as encode_name, from_hex_unicode as decode_name
@ -336,9 +337,12 @@ class RotatingStream(object):
kwargs['safe_encode'] = True
kwargs['file'] = self.stream
self.current_pos += prints(*args, **kwargs)
if iswindows:
if iswindows or ispy3:
# For some reason line buffering does not work on windows
# and in python 3 it only works with text mode streams
end = kwargs.get('end', b'\n')
if isinstance(end, unicode_type):
end = end.encode('utf-8')
if b'\n' in end:
self.flush()
self.rollover()