diff --git a/.travis.yml b/.travis.yml index e1529542..a85a4d06 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ env: - TOXENV=py26 - TOXENV=py27 - TOXENV=py32 + - TOXENV=py33 install: - pip install --quiet --use-mirrors tox script: diff --git a/jedi/_compatibility.py b/jedi/_compatibility.py index a3489869..331c1f11 100644 --- a/jedi/_compatibility.py +++ b/jedi/_compatibility.py @@ -9,7 +9,6 @@ will be dropped, we'll get rid of most code. import sys import imp import os -import io try: import importlib except: @@ -31,11 +30,14 @@ def find_module_py33(string, path=None): raise ImportError try: - filename = importing.get_filename(string) - if filename and os.path.exists(filename): - returning = (open(filename, 'U'), filename, False) + if (importing.is_package(string)): + returning = (None, os.path.dirname(importing.path), True) else: - returning = (None, filename, False) + filename = importing.get_filename(string) + if filename and os.path.exists(filename): + returning = (open(filename, 'U'), filename, False) + else: + returning = (None, filename, False) except AttributeError: returning = (None, importing.load_module(string).__name__, False) diff --git a/jedi/cache.py b/jedi/cache.py index 2b671700..5d76f24e 100644 --- a/jedi/cache.py +++ b/jedi/cache.py @@ -222,7 +222,7 @@ def save_module(path, name, parser, pickling=True): class _ModulePickling(object): - version = 1 + version = 2 """ Version number (integer) for file system cache. diff --git a/jedi/imports.py b/jedi/imports.py index a006f3e7..db72925f 100644 --- a/jedi/imports.py +++ b/jedi/imports.py @@ -5,9 +5,8 @@ any actual importing done. This module is about finding modules in the filesystem. This can be quite tricky sometimes, because Python imports are not always that simple. -Currently the import process uses ``imp`` to find modules. In the future, it's -a goal to use ``importlib`` for this purpose. There's a `pull request -`_ for that. +This module uses imp for python up to 3.2 and importlib for python 3.3 on; the +correct implementation is delegated to _compatibility. This module also supports import autocompletion, which means to complete statements like ``from datetim`` (curser at the end would return ``datetime``). @@ -17,7 +16,6 @@ from __future__ import with_statement import os import pkgutil -import imp import sys import itertools diff --git a/jedi/parsing_representation.py b/jedi/parsing_representation.py index d1ea83ff..311f38ab 100644 --- a/jedi/parsing_representation.py +++ b/jedi/parsing_representation.py @@ -560,8 +560,10 @@ class Flow(Scope): @parent.setter def parent(self, value): self._parent = value - if hasattr(self, "next") and self.next: + try: self.next.parent = value + except AttributeError: + return def get_code(self, first_indent=False, indention=' '): stmts = [] diff --git a/tox.ini b/tox.ini index 6dc16930..8fa50614 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py25, py26, py27, py32 +envlist = py25, py26, py27, py32, py33 [testenv] deps = pytest