Patchwork [5,of,7] httpclient: don't use mutable default argument value

login
register
mail settings
Submitter Pierre-Yves David
Date March 15, 2017, 7:01 a.m.
Message ID <855f0045de7f94630923.1489561277@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/19351/
State Accepted
Headers show

Comments

Pierre-Yves David - March 15, 2017, 7:01 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1489560565 25200
#      Tue Mar 14 23:49:25 2017 -0700
# Node ID 855f0045de7f94630923be4639f234b28be89e7f
# Parent  92e6b5422e92f0ad7707289335d9d40fb7c7da98
# EXP-Topic check-pylint
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 855f0045de7f
httpclient: don't use mutable default argument value

Caught by pylint.

Patch

diff --git a/mercurial/httpclient/__init__.py b/mercurial/httpclient/__init__.py
--- a/mercurial/httpclient/__init__.py
+++ b/mercurial/httpclient/__init__.py
@@ -631,7 +631,7 @@  class HTTPConnection(object):
         self.close()
         self._connect(pheaders)
 
-    def request(self, method, path, body=None, headers={},
+    def request(self, method, path, body=None, headers=None,
                 expect_continue=False):
         """Send a request to the server.
 
@@ -642,6 +642,8 @@  class HTTPConnection(object):
         available. Use the `getresponse()` method to retrieve the
         response.
         """
+        if headers is None:
+            headers = {}
         method = _ensurebytes(method)
         path = _ensurebytes(path)
         if self.busy():