Skip to content

Commit

Permalink
rollback to previous version of jedi as new one was causing problems …
Browse files Browse the repository at this point in the history
…with travis and was completely broke in pypy3
  • Loading branch information
DamnWidget committed Aug 25, 2016
1 parent 7b9eba1 commit 36bc7ed
Show file tree
Hide file tree
Showing 47 changed files with 4,377 additions and 4,804 deletions.
2 changes: 1 addition & 1 deletion anaconda_lib/jedi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
good text editor, while still having very good IDE features for Python.
"""

__version__ = '0.10.0'
__version__ = '0.9.0'

from jedi.api import Script, Interpreter, NotFoundError, set_debug_function
from jedi.api import preload_module, defined_names, names
Expand Down
19 changes: 7 additions & 12 deletions anaconda_lib/jedi/__main__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import sys
from sys import argv
from os.path import join, dirname, abspath, isdir


def _start_linter():
if len(argv) == 2 and argv[1] == 'repl':
# don't want to use __main__ only for repl yet, maybe we want to use it for
# something else. So just use the keyword ``repl`` for now.
print(join(dirname(abspath(__file__)), 'api', 'replstartup.py'))
elif len(argv) > 1 and argv[1] == 'linter':
"""
This is a pre-alpha API. You're not supposed to use it at all, except for
testing. It will very likely change.
"""
import jedi
import sys

if '--debug' in sys.argv:
jedi.set_debug_function()
Expand All @@ -32,17 +37,7 @@ def _start_linter():
print(error)
except Exception:
if '--pdb' in sys.argv:
import traceback
traceback.print_exc()
import pdb
pdb.post_mortem()
else:
raise


if len(sys.argv) == 2 and sys.argv[1] == 'repl':
# don't want to use __main__ only for repl yet, maybe we want to use it for
# something else. So just use the keyword ``repl`` for now.
print(join(dirname(abspath(__file__)), 'api', 'replstartup.py'))
elif len(sys.argv) > 1 and sys.argv[1] == 'linter':
_start_linter()
74 changes: 8 additions & 66 deletions anaconda_lib/jedi/_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,16 @@
import imp
import os
import re
import pkgutil
try:
import importlib
except ImportError:
pass

is_py3 = sys.version_info[0] >= 3
is_py33 = is_py3 and sys.version_info.minor >= 3
is_py34 = is_py3 and sys.version_info.minor >= 4
is_py35 = is_py3 and sys.version_info.minor >= 5
is_py26 = not is_py3 and sys.version_info[1] < 7


class DummyFile(object):
def __init__(self, loader, string):
self.loader = loader
self.string = string

def read(self):
return self.loader.get_source(self.string)

def close(self):
del self.loader


def find_module_py33(string, path=None):
loader = importlib.machinery.PathFinder.find_module(string, path)

Expand All @@ -40,81 +25,38 @@ def find_module_py33(string, path=None):
except ValueError as e:
# See #491. Importlib might raise a ValueError, to avoid this, we
# just raise an ImportError to fix the issue.
raise ImportError("Originally " + repr(e))
raise ImportError("Originally ValueError: " + e.message)

if loader is None:
raise ImportError("Couldn't find a loader for {0}".format(string))

try:
is_package = loader.is_package(string)
if is_package:
if hasattr(loader, 'path'):
module_path = os.path.dirname(loader.path)
else:
# At least zipimporter does not have path attribute
module_path = os.path.dirname(loader.get_filename(string))
if hasattr(loader, 'archive'):
module_file = DummyFile(loader, string)
else:
module_file = None
module_path = os.path.dirname(loader.path)
module_file = None
else:
module_path = loader.get_filename(string)
module_file = DummyFile(loader, string)
module_file = open(module_path, 'rb')
except AttributeError:
# ExtensionLoader has not attribute get_filename, instead it has a
# path attribute that we can use to retrieve the module path
try:
module_path = loader.path
module_file = DummyFile(loader, string)
module_file = open(loader.path, 'rb')
except AttributeError:
module_path = string
module_file = None
finally:
is_package = False

if hasattr(loader, 'archive'):
module_path = loader.archive

return module_file, module_path, is_package


def find_module_pre_py33(string, path=None):
try:
module_file, module_path, description = imp.find_module(string, path)
module_type = description[2]
return module_file, module_path, module_type is imp.PKG_DIRECTORY
except ImportError:
pass

if path is None:
path = sys.path
for item in path:
loader = pkgutil.get_importer(item)
if loader:
try:
loader = loader.find_module(string)
if loader:
is_package = loader.is_package(string)
is_archive = hasattr(loader, 'archive')
try:
module_path = loader.get_filename(string)
except AttributeError:
# fallback for py26
try:
module_path = loader._get_filename(string)
except AttributeError:
continue
if is_package:
module_path = os.path.dirname(module_path)
if is_archive:
module_path = loader.archive
file = None
if not is_package or is_archive:
file = DummyFile(loader, string)
return (file, module_path, is_package)
except ImportError:
pass
raise ImportError("No module named {0}".format(string))
module_file, module_path, description = imp.find_module(string, path)
module_type = description[2]
return module_file, module_path, module_type is imp.PKG_DIRECTORY


find_module = find_module_py33 if is_py33 else find_module_pre_py33
Expand Down
Loading

0 comments on commit 36bc7ed

Please sign in to comment.