From b31b456dd4d967207924fd1afe1495863f7e413e Mon Sep 17 00:00:00 2001 From: bstaint Date: Mon, 1 Aug 2016 01:13:39 +0800 Subject: [PATCH] Fixed Windows slashes problem. --- AUTHORS.txt | 1 + jedi/evaluate/compiled/__init__.py | 6 +++++- test/test_windows.py | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/test_windows.py diff --git a/AUTHORS.txt b/AUTHORS.txt index ad4a007f..bbd7ecdf 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -39,6 +39,7 @@ Reinoud Elhorst (@reinhrst) Guido van Rossum (@gvanrossum) Dmytro Sadovnychyi (@sadovnychyi) Cristi Burcă (@scribu) +bstaint (@bstaint) Note: (@user) means a github user name. diff --git a/jedi/evaluate/compiled/__init__.py b/jedi/evaluate/compiled/__init__.py index 2660734b..1a5bebb4 100644 --- a/jedi/evaluate/compiled/__init__.py +++ b/jedi/evaluate/compiled/__init__.py @@ -339,7 +339,11 @@ def dotted_from_fs_path(fs_path, sys_path): for s in sys_path: if (fs_path.startswith(s) and len(path) < len(s)): path = s - return _path_re.sub('', fs_path[len(path):].lstrip(os.path.sep)).replace(os.path.sep, '.') + + # - Window + # X:\path\to\lib-dynload/datetime.pyd => datetime + module_path = fs_path[len(path):].lstrip(os.path.sep).lstrip('/') + return _path_re.sub('', module_path).replace(os.path.sep, '.') def load_module(evaluator, path=None, name=None): diff --git a/test/test_windows.py b/test/test_windows.py new file mode 100644 index 00000000..e5d8cd0d --- /dev/null +++ b/test/test_windows.py @@ -0,0 +1,8 @@ +import jedi + +def test_path_issues(): + """ + See pull request #684 for details. + """ + source = '''from datetime import ''' + assert jedi.Script(source).completions()