[PATCH 2 of 2 V3] error: make hintable exceptions reject unknown keyword arguments (API)
Yuya Nishihara
yuya at tcha.org
Mon Jul 11 14:28:19 UTC 2016
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1468240802 -32400
# Mon Jul 11 21:40:02 2016 +0900
# Node ID 292f0845baa57737bc9b8ce9d21d124dba157cc2
# Parent 5a15266e4b16eb9dba59fa561a2c3b6d3214db4b
error: make hintable exceptions reject unknown keyword arguments (API)
Previously they would accept any typos of the hint keyword.
diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -18,12 +18,12 @@ from __future__ import absolute_import
class Hint(object):
"""Mix-in to provide a hint of an error
- This should come first in the inheritance list to consume **kw and pass
- only *args to the exception class.
+ This should come first in the inheritance list to consume a hint and
+ pass remaining arguments to the exception class.
"""
def __init__(self, *args, **kw):
- super(Hint, self).__init__(*args)
- self.hint = kw.get('hint')
+ self.hint = kw.pop('hint', None)
+ super(Hint, self).__init__(*args, **kw)
class RevlogError(Hint, Exception):
pass
diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -56,9 +56,9 @@ def _getstorehashcachename(remotepath):
class SubrepoAbort(error.Abort):
"""Exception class used to avoid handling a subrepo error more than once"""
def __init__(self, *args, **kw):
+ self.subrepo = kw.pop('subrepo', None)
+ self.cause = kw.pop('cause', None)
error.Abort.__init__(self, *args, **kw)
- self.subrepo = kw.get('subrepo')
- self.cause = kw.get('cause')
def annotatesubrepoerror(func):
def decoratedmethod(self, *args, **kargs):
More information about the Mercurial-devel
mailing list