Patchwork D7286: match: suppress error about subscripting an exception

login
register
mail settings
Submitter phabricator
Date Nov. 6, 2019, 11 p.m.
Message ID <differential-rev-PHID-DREV-p43ej3nfeytygs7wooxz-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/42840/
State Superseded
Headers show

Comments

phabricator - Nov. 6, 2019, 11 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I get the sense I should file a bug about subscripting Exception subclasses.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/match.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel
phabricator - Nov. 7, 2019, 8:21 a.m.
This revision is now accepted and ready to land.
indygreg added a comment.
indygreg accepted this revision.


  Regarding filing a bug, ISTR exception subscription is deprecated (or at least discouraged) in modern Python versions: I believe you are encouraged to access e.g. `e.message` now. But I'm fine suppressing these for now until Python formally deprecates it by emitting a `DeprecationWarning`.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7286/new/

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

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

Patch

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -345,7 +345,9 @@ 
                 ):
                     kindpats.append((k, p, source or pat))
             except error.Abort as inst:
-                raise error.Abort(b'%s: %s' % (pat, inst[0]))
+                raise error.Abort(
+                    b'%s: %s' % (pat, inst[0])
+                )  # pytype: disable=unsupported-operands
             except IOError as inst:
                 if warn:
                     warn(