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

Yuya Nishihara yuya at tcha.org
Tue Apr 23 19:25:07 EDT 2019


On Tue, 23 Apr 2019 01:57:32 +0000, Ludovic Chabant wrote:
> # 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'):

We still need to use getattr(..., None) to silence test-check-code.t.

> +                    spec = finder.find_spec(fullname, path, target=target)
> +                else:
> +                    spec = finder.find_module(fullname, path)

Does find_module() return a spec? We might instead have to skip py3.4 finders.


More information about the Mercurial-devel mailing list