Patchwork D2882: hgweb: convert an assert to a ProgrammingError

login
register
mail settings
Submitter phabricator
Date March 16, 2018, 7:15 p.m.
Message ID <differential-rev-PHID-DREV-iebw3jlb62mitdgolcez-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/29571/
State Superseded
Headers show

Comments

phabricator - March 16, 2018, 7:15 p.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Because assert may get optimized away.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/hgweb/webcommands.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -1195,7 +1195,9 @@ 
         web.res.headers['Content-Encoding'] = encoding
 
     web.res.setbodywillwrite()
-    assert list(web.res.sendresponse()) == []
+    if list(web.res.sendresponse()):
+        raise error.ProgrammingError('sendresponse() should not emit data '
+                                     'if writing later')
 
     bodyfh = web.res.getbodyfile()