[PATCH 1 of 2] import-checker: increase portability for python 2.6.x
timeless
timeless at gmail.com
Tue Jun 21 08:23:28 EDT 2016
IMO this should have a comment saying we can return to None when we drop 2.6
On Jun 18, 2016 1:21 PM, "FUJIWARA Katsunori" <foozy at lares.dti.ne.jp> wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> # Date 1466270109 -32400
> # Sun Jun 19 02:15:09 2016 +0900
> # Node ID 04da1198949bcd8c1d1fd6675816eacfdc2f3dcf
> # Parent 4e6e280e238fa885df9e0e600dc5915a71c8a37a
> import-checker: increase portability for python 2.6.x
>
> Before this patch, fromlocalfunc() assumes that "module" attribute of
> ast.ImportFrom is None for "from . import a", and Python 2.7.x
> satisfies this assumption.
>
> On the other hand, with Python 2.6.x, "module" attribute of
> ast.ImportFrom is an empty string for "from . import a", and this
> causes failure of test-check-module-imports.t.
>
> diff --git a/contrib/import-checker.py b/contrib/import-checker.py
> --- a/contrib/import-checker.py
> +++ b/contrib/import-checker.py
> @@ -141,8 +141,8 @@ def fromlocalfunc(modulename, localmods)
> if prefix:
> prefix += '.'
> def fromlocal(name, level=0):
> - # name is None when relative imports are used.
> - if name is None:
> + # name is false value when relative imports are used.
> + if not name:
> # If relative imports are used, level must not be absolute.
> assert level > 0
> candidates = ['.'.join(modulename.split('.')[:-level])]
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20160621/ed185ab1/attachment.html>
More information about the Mercurial-devel
mailing list