Patchwork D6840: hgweb: add a `message` attribute to `hgweb.common.ErrorResponse`

login
register
mail settings
Submitter phabricator
Date Sept. 10, 2019, 8:10 p.m.
Message ID <differential-rev-PHID-DREV-fvxuxjg7ngiwkfx6j6an-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/41635/
State Superseded
Headers show

Comments

phabricator - Sept. 10, 2019, 8:10 p.m.
sheehan created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This fixes a Python 3 bug where hgweb assumes an Exception
  subclass will have a `.message` attribute after running
  `Exception.__init__`.[1] The Python 3 way to get this info would
  be `e.args[0]`, but adding a new named attribute is more
  ergonomic in my view.
  
  [1] https://www.mercurial-scm.org/repo/hg-committed/file/6ccf539aec71/mercurial/hgweb/hgwebdir_mod.py#l459

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6840

AFFECTED FILES
  mercurial/hgweb/common.py

CHANGE DETAILS




To: sheehan, #hg-reviewers
Cc: mercurial-devel
phabricator - Sept. 10, 2019, 8:13 p.m.
sheehan added a comment.


  The error I mentioned looks like this:
  
    Traceback (most recent call last):
      File "/var/hg/venv_hgweb/lib64/python3.6/site-packages/mercurial/hgweb/hgwebdir_mod.py", line 358, in run_wsgi
        for r in self._runwsgi(req, res):
      File "/var/hg/venv_hgweb/lib64/python3.6/site-packages/mercurial/hgweb/hgwebdir_mod.py", line 463, in _runwsgi
        res.setbodygen(tmpl.generate('error', {'error': e.message or ''}))
    AttributeError: 'ErrorResponse' object has no attribute 'message'

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6840/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D6840

To: sheehan, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/hgweb/common.py b/mercurial/hgweb/common.py
--- a/mercurial/hgweb/common.py
+++ b/mercurial/hgweb/common.py
@@ -106,6 +106,7 @@ 
         if headers is None:
             headers = []
         self.headers = headers
+        self.message = message
 
 class continuereader(object):
     """File object wrapper to handle HTTP 100-continue.