01-arcadia.patch 1.5 KB

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