launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25063
[Merge] ~cjwatson/launchpad:py3-importpedant into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-importpedant into launchpad:master.
Commit message:
Fix import_pedant for Python 3
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/387772
As of Python 3.3, the default value for the "level" argument to __import__ is 0, and the previous default of -1 (i.e. attempt both absolute and relative imports) is no longer supported.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-importpedant into launchpad:master.
diff --git a/lib/lp/scripts/utilities/importpedant.py b/lib/lp/scripts/utilities/importpedant.py
index bae2269..e332df7 100644
--- a/lib/lp/scripts/utilities/importpedant.py
+++ b/lib/lp/scripts/utilities/importpedant.py
@@ -8,6 +8,7 @@ import itertools
from operator import attrgetter
import types
+import six
from six.moves import builtins
@@ -183,7 +184,8 @@ class NotFoundPolicyViolation(PedantDisagreesError):
# The names of the arguments form part of the interface of __import__(...),
# and must not be changed, as code may choose to invoke __import__ using
# keyword arguments - e.g. the encodings module in Python 2.6.
-def import_pedant(name, globals={}, locals={}, fromlist=[], level=-1):
+def import_pedant(name, globals={}, locals={}, fromlist=[],
+ level=(0 if six.PY3 else -1)):
global naughty_imports
module = original_import(name, globals, locals, fromlist, level)