[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mercurial-devel
Subject:    Re: [PATCH 06 of 10] hgweb: don't use default mutable argument value
From:       Pierre-Yves David <pierre-yves.david () ens-lyon ! org>
Date:       2016-12-27 10:04:38
Message-ID: 74d31af2-0db8-3d33-29a7-8771fa9cb010 () ens-lyon ! org
[Download RAW message or body]



On 12/27/2016 01:03 AM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1482796613 25200
> #      Mon Dec 26 16:56:53 2016 -0700
> # Node ID cdb830b22b187debced54bd0d6e11e932bd7fdad
> # Parent  1b0f806daa5e47cd88f6c1364cff06d96c1809db
> hgweb: don't use default mutable argument value
>
> diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
> --- a/mercurial/hgweb/webutil.py
> +++ b/mercurial/hgweb/webutil.py
> @@ -141,9 +141,10 @@ class filerevnav(revnav):
>      def hex(self, rev):
>          return hex(self._changelog.node(self._revlog.linkrev(rev)))
>
>  class _siblings(object):
> -    def __init__(self, siblings=[], hiderev=None):
> +    def __init__(self, siblings=None, hiderev=None):
> +        siblings = siblings or []

Same feedback about testing for None or using ().

>          self.siblings = [s for s in siblings if s.node() != nullid]
>          if len(self.siblings) == 1 and self.siblings[0].rev() == hiderev:
>              self.siblings = []
>
> diff --git a/tests/test-check-code.t b/tests/test-check-code.t
> --- a/tests/test-check-code.t
> +++ b/tests/test-check-code.t
> @@ -57,11 +57,8 @@ New errors are not allowed. Warnings are
>     use encoding.environ instead (py3)
>    mercurial/exchange.py:1019:
>     > def _localphasemove(pushop, nodes, phase=phases.public):
>     attribute default argument value may be mutable
> -  mercurial/hgweb/webutil.py:145:
> -   >     def __init__(self, siblings=[], hiderev=None):
> -   mutable default argument value (list)
>    Skipping mercurial/httpclient/__init__.py it has no-che?k-code (glob)
>    Skipping mercurial/httpclient/_readers.py it has no-che?k-code (glob)
>    mercurial/match.py:88:
>     >     def __init__(self, root, cwd, patterns, include=[], exclude=[],
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

-- 
Pierre-Yves David
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic