Patchwork [6,of,8] hgweb: explicitly tests for None

login
register
mail settings
Submitter Pierre-Yves David
Date March 16, 2017, 11:28 a.m.
Message ID <28093cead8791382a984.1489663690@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/19391/
State Accepted
Headers show

Comments

Pierre-Yves David - March 16, 2017, 11:28 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1489615864 25200
#      Wed Mar 15 15:11:04 2017 -0700
# Node ID 28093cead8791382a984b4c80dcedbe529ea7c41
# Parent  1596b4613bec63db08c0d4d10e3f26f5635ce21b
# EXP-Topic mutable-default
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 28093cead879
hgweb: explicitly tests for None

Changeset 7dafa8d0e006 removed the mutable default value, but did not explicitly
tested for None. Such implicit testing can introduce semantic and performance
issue. We move to an explicit testing for None as recommended by PEP8:

https://www.python.org/dev/peps/pep-0008/#programming-recommendations

Patch

diff --git a/mercurial/hgweb/common.py b/mercurial/hgweb/common.py
--- a/mercurial/hgweb/common.py
+++ b/mercurial/hgweb/common.py
@@ -96,7 +96,9 @@  class ErrorResponse(Exception):
             message = _statusmessage(code)
         Exception.__init__(self, message)
         self.code = code
-        self.headers = headers or []
+        if headers is None:
+            headers = []
+        self.headers = headers
 
 class continuereader(object):
     def __init__(self, f, write):