[PATCH 1 of 2 v2] py3: handle meta-path finders that only use pre-python3.4 API

Ludovic Chabant ludovic at chabant.com
Mon Apr 22 21:57:32 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 8214209f30a56052124b7f530d2a955a2b93b14f
# Parent  4a8d9ed864754837a185a642170cde24392f9abf
py3: handle meta-path finders that only use pre-python3.4 API

diff --git a/mercurial/__init__.py b/mercurial/__init__.py
--- a/mercurial/__init__.py
+++ b/mercurial/__init__.py
@@ -54,7 +54,13 @@
                 if finder == self:
                     continue
 
-                spec = finder.find_spec(fullname, path, target=target)
+                # Originally the API was a `find_module` method, but it was
+                # renamed to `find_spec` in python 3.4, with a new `target`
+                # argument.
+                if hasattr(finder, 'find_spec'):
+                    spec = finder.find_spec(fullname, path, target=target)
+                else:
+                    spec = finder.find_module(fullname, path)
                 if spec:
                     break
 


More information about the Mercurial-devel mailing list