[PATCH 1 of 3] demandimport: remove support for Python < 2.5
Gregory Szorc
gregory.szorc at gmail.com
Sat Aug 8 18:41:23 CDT 2015
Please disregard this series beyond part 1. There be dragons in this code.
On Sat, Aug 8, 2015 at 4:31 PM, Gregory Szorc <gregory.szorc at gmail.com>
wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1439071287 25200
> # Sat Aug 08 15:01:27 2015 -0700
> # Node ID 4c1a937f7837d4dab00d1ab555ae6f53c2739eaf
> # Parent e5891ade62b1a4dba017fd9d7b8cacb4ab200014
> demandimport: remove support for Python < 2.5
>
> The removed code was to support an __import__ function that doesn't
> support the "level" argument. This argument was added in Python 2.5,
> which we no longer support.
>
> diff --git a/mercurial/demandimport.py b/mercurial/demandimport.py
> --- a/mercurial/demandimport.py
> +++ b/mercurial/demandimport.py
> @@ -36,20 +36,13 @@ except ImportError:
> _origimport = __import__
>
> nothing = object()
>
> -try:
> - # Python 3 doesn't have relative imports nor level -1.
> - level = -1
> - if sys.version_info[0] >= 3:
> - level = 0
> - _origimport(builtins.__name__, {}, {}, None, level)
> -except TypeError: # no level argument
> - def _import(name, globals, locals, fromlist, level):
> - "call _origimport with no level argument"
> - return _origimport(name, globals, locals, fromlist)
> -else:
> - _import = _origimport
> +# Python 3 doesn't have relative imports nor level -1.
> +level = -1
> +if sys.version_info[0] >= 3:
> + level = 0
> +_import = _origimport
>
> def _hgextimport(importfunc, name, globals, *args):
> try:
> return importfunc(name, globals, *args)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20150808/9e43b374/attachment.html>
More information about the Mercurial-devel
mailing list