Skip to content

Commit ee36bf9

Browse files
committed
handle_line_and_cell
1 parent 9754919 commit ee36bf9

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

IPython/core/magics/execution.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,12 +1338,14 @@ def time(self, line="", cell=None, local_ns=None):
13381338
Wall time: 0.00 s
13391339
Compiler : 0.78 s
13401340
"""
1341+
line_present = False
13411342
# Try to parse --no-raise-error if present, else ignore unrecognized args
13421343
try:
13431344
args = magic_arguments.parse_argstring(self.time, line)
13441345
except UsageError as e:
13451346
# Only ignore UsageError if caused by unrecognized arguments
13461347
# We'll manually check for --no-raise-error and remove it from line
1348+
line_present = True
13471349
tokens = shlex.split(line)
13481350
no_raise_error = False
13491351
filtered_tokens = []
@@ -1364,6 +1366,9 @@ def __init__(self, no_raise_error):
13641366
if not hasattr(args, "no_raise_error"):
13651367
args.no_raise_error = False
13661368

1369+
if line_present and cell:
1370+
raise UsageError("Can't use statement directly after '%%time'!")
1371+
13671372
if cell:
13681373
expr = self.shell.transform_cell(cell)
13691374
else:

0 commit comments

Comments
 (0)