From 58b165e4b60cee264d7cadc4694177229017aa31 Mon Sep 17 00:00:00 2001 From: Laurens Van Houtven <_@lvh.cc> Date: Sun, 23 Jun 2013 22:02:37 +0200 Subject: [PATCH] Don't assume either namespace is not-None --- jedi/parsing_representation.py | 2 +- test/test_absolute_import.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jedi/parsing_representation.py b/jedi/parsing_representation.py index 206feed1..59b11bca 100644 --- a/jedi/parsing_representation.py +++ b/jedi/parsing_representation.py @@ -333,7 +333,7 @@ def _enables_absolute_import(imp): Checks if the import is a ``__future__`` import that enables the ``absolute_import`` feature. """ - if imp.namespace is None: + if imp.from_ns is None or imp.namespace is None: return False namespace, feature = imp.from_ns.names[0], imp.namespace.names[0] diff --git a/test/test_absolute_import.py b/test/test_absolute_import.py index bfa3b490..343ce970 100644 --- a/test/test_absolute_import.py +++ b/test/test_absolute_import.py @@ -24,7 +24,7 @@ def test_py2_imports_are_not_always_absolute(): def test_dont_break_imports_without_namespaces(): """ The code checking for ``from __future__ import absolute_import`` shouldn't - assume that all imports have non-``None`` ``namespace`` attributes. + assume that all imports have non-``None`` namespaces. """ src = "from __future__ import absolute_import\nimport xyzzy" parser = Parser(src, "test.py")