[PATCH 1 of 2] py3: protect from exceptions thrown by other meta-path finders

Ludovic Chabant ludovic at chabant.com
Fri Apr 19 10:34:13 EDT 2019


# HG changeset patch
# User Ludovic Chabant <ludovic at chabant.com>
# Date 1555683918 0
#      Fri Apr 19 14:25:18 2019 +0000
# Branch stable
# Node ID 96a51193678400abf9d04af65e60a8dccf540cd7
# Parent  4a8d9ed864754837a185a642170cde24392f9abf
py3: protect from exceptions thrown by other meta-path finders

diff --git a/mercurial/__init__.py b/mercurial/__init__.py
--- a/mercurial/__init__.py
+++ b/mercurial/__init__.py
@@ -54,9 +54,14 @@
                 if finder == self:
                     continue
 
-                spec = finder.find_spec(fullname, path, target=target)
-                if spec:
-                    break
+                try:
+                    spec = finder.find_spec(fullname, path, target=target)
+                    if spec:
+                        break
+                except:
+                    # Some finders don't implement `find_spec`, like
+                    # `_SixMetaPathImporter`.
+                    pass
 
             # This is a Mercurial-related module but we couldn't find it
             # using the previously-registered finders. This likely means


More information about the Mercurial-devel mailing list