blob: 48f5d781a01a1e091416694091f77c5e48b62726 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
--- contrib/python/jedi/py2/jedi/evaluate/compiled/fake.py (index)
+++ contrib/python/jedi/py2/jedi/evaluate/compiled/fake.py (working tree)
@@ -3,22 +3,26 @@ Loads functions that are mixed in to the standard library. E.g. builtins are
written in C (binaries), but my autocompletion only understands Python code. By
mixing in Python code, the autocompletion should work much better for builtins.
"""
-
+import sys
import os
from itertools import chain
+import __res
+
from jedi._compatibility import unicode
fake_modules = {}
def _get_path_dict():
- path = os.path.dirname(os.path.abspath(__file__))
+ path = os.path.dirname(__file__)
base_path = os.path.join(path, 'fake')
dct = {}
- for file_name in os.listdir(base_path):
- if file_name.endswith('.pym'):
- dct[file_name[:-4]] = os.path.join(base_path, file_name)
+ for file_name in __res.resfs_files():
+ if sys.version_info[0] == 3:
+ file_name = str(file_name, 'ascii')
+ if file_name.startswith(base_path) and file_name.endswith('.pym'):
+ dct[file_name[len(base_path) + 1:-4]] = file_name
return dct
@@ -45,8 +49,9 @@ def _load_faked_module(evaluator, module_name):
fake_modules[module_name] = None
return
- with open(path) as f:
- source = f.read()
+ if sys.version_info[0] == 3:
+ path = bytes(path, 'ascii')
+ source = __res.resfs_read(path)
fake_modules[module_name] = m = evaluator.latest_grammar.parse(unicode(source))
|