[PATCH 4 of 6] wsgiheaders: make sure __repr__() returns a string

Matt Harbison mharbison72 at gmail.com
Tue Feb 5 21:35:47 EST 2019


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1549401374 18000
#      Tue Feb 05 16:16:14 2019 -0500
# Node ID 1a4bd7696b7e12673ddc46733babd15151f00e05
# Parent  576aec428b05a88584505b9c4af541e273e1014a
wsgiheaders: make sure __repr__() returns a string

When printing `req.headers` on the server side to debug, it complained that '%b'
needed to take a string, not bytes.  Changing '%s' to '%r' caused it to complain
that __repr__ didn't return a string.

diff --git a/mercurial/hgweb/wsgiheaders.py b/mercurial/hgweb/wsgiheaders.py
--- a/mercurial/hgweb/wsgiheaders.py
+++ b/mercurial/hgweb/wsgiheaders.py
@@ -127,7 +127,7 @@ class Headers(object):
         return self._headers[:]
 
     def __repr__(self):
-        return "%s(%r)" % (self.__class__.__name__, self._headers)
+        return r"%s(%r)" % (self.__class__.__name__, self._headers)
 
     def __str__(self):
         """str() returns the formatted headers, complete with end line,


More information about the Mercurial-devel mailing list