Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b4327a0

Browse files
authored
Revert "fix semicolon detection with no history"
1 parent b7c9c36 commit b4327a0

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

IPython/core/displayhook.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(self, shell=None, cache_size=1000, **kwargs):
5151

5252
# we need a reference to the user-level namespace
5353
self.shell = shell
54-
54+
5555
self._,self.__,self.___ = '','',''
5656

5757
# these are deliberately global:
@@ -83,9 +83,15 @@ def check_for_underscore(self):
8383

8484
def quiet(self):
8585
"""Should we silence the display hook because of ';'?"""
86-
if self.exec_result is not None:
87-
return self.semicolon_at_end_of_expression(self.exec_result.info.raw_cell)
88-
return False
86+
# do not print output if input ends in ';'
87+
88+
try:
89+
cell = self.shell.history_manager.input_hist_parsed[-1]
90+
except IndexError:
91+
# some uses of ipshellembed may fail here
92+
return False
93+
94+
return self.semicolon_at_end_of_expression(cell)
8995

9096
@staticmethod
9197
def semicolon_at_end_of_expression(expression):
@@ -274,12 +280,13 @@ def cull_cache(self):
274280
cull_count = max(int(sz * self.cull_fraction), 2)
275281
warn('Output cache limit (currently {sz} entries) hit.\n'
276282
'Flushing oldest {cull_count} entries.'.format(sz=sz, cull_count=cull_count))
277-
283+
278284
for i, n in enumerate(sorted(oh)):
279285
if i >= cull_count:
280286
break
281287
self.shell.user_ns.pop('_%i' % n, None)
282288
oh.pop(n, None)
289+
283290

284291
def flush(self):
285292
if not self.do_full_cache:

0 commit comments

Comments
 (0)