From 463cbb15959a8c86b61c8250f4fa19dce7cbab69 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Thu, 8 Aug 2019 09:31:13 +0200 Subject: [PATCH] Fix one more os.path.join issue --- jedi/plugins/stdlib.py | 8 ++++++-- test/test_api/test_completion.py | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/jedi/plugins/stdlib.py b/jedi/plugins/stdlib.py index 7a07494d..57e2c1e0 100644 --- a/jedi/plugins/stdlib.py +++ b/jedi/plugins/stdlib.py @@ -708,14 +708,18 @@ def _os_path_join(args_set, callback): if len(args_set) == 1: string = u'' sequence, = args_set + is_first = True for lazy_context in sequence.py__iter__(): string_contexts = lazy_context.infer() if len(string_contexts) != 1: break s = get_str_or_none(next(iter(string_contexts))) - if string is None: + if s is None: break - string += os.path.sep + force_unicode(s) + if not is_first: + string += os.path.sep + string += force_unicode(s) + is_first = False else: return ContextSet([compiled.create_simple_object(sequence.evaluator, string)]) return callback() diff --git a/test/test_api/test_completion.py b/test/test_api/test_completion.py index a9dc66e1..2e52240b 100644 --- a/test/test_api/test_completion.py +++ b/test/test_api/test_completion.py @@ -210,6 +210,9 @@ os_path = 'from os.path import *\n' (f2, os_path + 'dirname(__file__) + "%stest_ca' % s, None, ['che.py']), (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py']), (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py']), + (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py']), + + # inside join (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']), (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']), (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py"']),