Skip to content

Commit 18e4529

Browse files
authored
suggested fix for autocall failure (ipython#14555)
Closes : ipython#14513 Following the recommendation in that Issue seems to fix the autocall issue (for at least the reproduction case) FYI: @Carreau since I saw you were assigned to the Issue. I only did the manual verification of the example case in the issue.
2 parents 02545e9 + 3e0dafa commit 18e4529

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

IPython/core/prefilter.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,10 @@ def check(self, line_info):
512512
callable(oinfo.obj)
513513
and (not self.exclude_regexp.match(line_info.the_rest))
514514
and self.function_name_regexp.match(line_info.ifun)
515-
and line_info.raw_the_rest.startswith(" ")
516-
or not line_info.raw_the_rest.strip()
515+
and (
516+
line_info.raw_the_rest.startswith(" ")
517+
or not line_info.raw_the_rest.strip()
518+
)
517519
):
518520
return self.prefilter_manager.get_handler_by_name("auto")
519521
else:

IPython/core/tests/test_prefilter.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,13 @@ def test_autocall_should_support_unicode():
137137
finally:
138138
ip.run_line_magic("autocall", "0")
139139
del ip.user_ns["π"]
140+
141+
142+
def test_autocall_regression_gh_14513():
143+
ip.run_line_magic("autocall", "2")
144+
ip.user_ns["foo"] = dict()
145+
try:
146+
assert ip.prefilter("foo") == "foo"
147+
finally:
148+
ip.run_line_magic("autocall", "0")
149+
del ip.user_ns["foo"]

0 commit comments

Comments
 (0)