From d0226573c055e35ba1e3e3b1b0b51ee93d5ed9b1 2024-10-25 08:37:44 From: M Bussonnier Date: 2024-10-25 08:37:44 Subject: [PATCH] Fix line stripping edge case for %load magic command (#14495) Closes: #14494 --- diff --git a/IPython/core/magics/code.py b/IPython/core/magics/code.py index 4f1574d..834ca51 100644 --- a/IPython/core/magics/code.py +++ b/IPython/core/magics/code.py @@ -153,7 +153,9 @@ def strip_initial_indent(lines): for line in it: if line.startswith(indent): - yield line[len(indent):] + yield line[len(indent) :] + elif line in ("\n", "\r\n") or len(line) == 0: + yield line else: # Less indented than the first line - stop dedenting yield line