From ba6297a070da14441b239915dfb758d238ed5eb8 Mon Sep 17 00:00:00 2001 From: David Halter Date: Mon, 10 Dec 2012 19:31:57 +0100 Subject: [PATCH] fix for a problem with get_in_function_call, if parentheses were not closed. --- jedi/helpers.py | 1 + jedi/parsing.py | 3 ++- test/regression.py | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/jedi/helpers.py b/jedi/helpers.py index fe1c927e..b1f6e4c7 100644 --- a/jedi/helpers.py +++ b/jedi/helpers.py @@ -202,6 +202,7 @@ def generate_param_array(args_tuple, parent_stmt=None): def scan_array_for_pos(arr, pos): """ Returns the function Call that match search_name in an Array. + Makes changes to arr! """ def check_arr_index(): positions = arr.arr_el_pos diff --git a/jedi/parsing.py b/jedi/parsing.py index 1b61f86b..942f329c 100644 --- a/jedi/parsing.py +++ b/jedi/parsing.py @@ -1027,7 +1027,8 @@ class Array(Call): if self.type in (Array.LIST, Array.TUPLE): return # these are basically code errors, just ignore self.keys.append(self.values.pop()) - self.type = Array.DICT + if self.type == Array.DICT: + self.type = Array.DICT self.values.append([]) def get_only_subelement(self): diff --git a/test/regression.py b/test/regression.py index 68441ab9..d3970394 100755 --- a/test/regression.py +++ b/test/regression.py @@ -208,6 +208,24 @@ class TestRegression(Base): "func(alpha='101'," assert check(self.get_in_function_call(s, (2, 13)), 'func', 0) + def test_get_in_function_call_complex(self): + def check(call_def, name, index): + return call_def and call_def.call_name == name \ + and call_def.index == index + + s = """ + def abc(a,b): + pass + + def a(self): + abc( + + if 1: + pass + """ + assert check(self.get_in_function_call(s, (6, 24)), 'abc', 0) + + def test_add_dynamic_mods(self): api.settings.additional_dynamic_modules = ['dynamic.py'] # Fictional module that defines a function.