Patchwork [08,of,11] py3: force hgweb.server error log to internally write unicode

login
register
mail settings
Submitter Matt Harbison
Date Jan. 28, 2019, 5:20 a.m.
Message ID <2db104a67b26ee9ff2f2.1548652854@Envy>
Download mbox | patch
Permalink /patch/38134/
State Accepted
Headers show

Comments

Matt Harbison - Jan. 28, 2019, 5:20 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1548632057 18000
#      Sun Jan 27 18:34:17 2019 -0500
# Node ID 2db104a67b26ee9ff2f2b9ba8bb98d52bada7bb9
# Parent  b98988169d4a9c7890b93091683fa4ec38d61a47
py3: force hgweb.server error log to internally write unicode

Otherwise, there's a lot of py2/py3 divergence in the LFS tests because of the
"HG error" lines picking up a b'' prefix.  wsgicgi.py uses procutil.stderr, so I
assume the input was meant to be bytes.

Patch

diff --git a/mercurial/hgweb/server.py b/mercurial/hgweb/server.py
--- a/mercurial/hgweb/server.py
+++ b/mercurial/hgweb/server.py
@@ -54,7 +54,7 @@  class _error_logger(object):
         self.writelines(str.split('\n'))
     def writelines(self, seq):
         for msg in seq:
-            self.handler.log_error("HG error:  %s", msg)
+            self.handler.log_error(r"HG error:  %s", encoding.strfromlocal(msg))
 
 class _httprequesthandler(httpservermod.basehttprequesthandler):