Patchwork D8902: templater: replace Py3-only exception types by super-types available in Py2

login
register
mail settings
Submitter phabricator
Date Aug. 6, 2020, 5:27 a.m.
Message ID <differential-rev-PHID-DREV-g7m4rr2aybx6pad6xjzc-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47001/
State Superseded
Headers show

Comments

phabricator - Aug. 6, 2020, 5:27 a.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  As noted by @indygreg, `test-check-pyflakes.t` started failing on Py2
  after my recent D8894 <https://phab.mercurial-scm.org/D8894>, because that introduced catching of the
  Py3-only types `ModuleNotFoundError` and `FileNotFoundError`. Let's
  switch to less precise types that are also available in Py2.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/templater.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: indygreg, mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -1107,5 +1107,5 @@ 
                 name,
                 resourceutil.open_resource(package_name, name_parts[-1]),
             )
-        except (ModuleNotFoundError, FileNotFoundError):
+        except (ImportError, OSError):
             return None, None