From aa8efc504db0d1828762f9645c62fd9c2bf7cd61 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Thu, 9 May 2019 13:26:33 -0400 Subject: [PATCH] py3: make user auth work; don't mess with encodings for strftime The Windows-specific hack initially added in commit 8743efbed1e54d8dd4e71ba71ebd5a7806564270 should be able to be removed now as it is no longer necessary. The python encoding on Windows is sane in python3. --- src/calibre/srv/utils.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/calibre/srv/utils.py b/src/calibre/srv/utils.py index 6575787519..f82cce7eac 100644 --- a/src/calibre/srv/utils.py +++ b/src/calibre/srv/utils.py @@ -22,7 +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.builtins import is_py3, 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 @@ -530,10 +530,9 @@ def get_use_roman(): return _use_roman -if iswindows: +if iswindows and not is_py3: def fast_now_strftime(fmt): - fmt = fmt.encode('mbcs') - return time.strftime(fmt).decode('mbcs', 'replace') + return time.strftime(fmt).encode('mbcs', 'replace').decode('mbcs') else: def fast_now_strftime(fmt): - return time.strftime(fmt).decode('utf-8', 'replace') + return time.strftime(fmt)