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

login
register
mail settings
Submitter Matt Harbison
Date Feb. 6, 2019, 2:35 a.m.
Message ID <1a4bd7696b7e12673ddc.1549420547@Envy>
Download mbox | patch
Permalink /patch/38471/
State Accepted
Headers show

Comments

Matt Harbison - Feb. 6, 2019, 2:35 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@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.

Patch

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,