Skip to content

Commit 777fb4c

Browse files
committed
Defer subprocess.CalledProcessError in core/magics/script.py
`%%script` only raises it when a cell exits non-zero under `--raise-error`, so the import moves into `shebang`, next to the other imports it already defers. This no longer changes what is imported at startup: `subprocess` is now pulled in by `asyncio.base_events`, via the prompt_toolkit import in `terminal/interactiveshell.py`, which an interactive terminal needs anyway.
1 parent ae73e53 commit 777fb4c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

IPython/core/magics/script.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import time
1212
import weakref
1313
from codecs import getincrementaldecoder
14-
from subprocess import CalledProcessError
1514
from threading import Thread
1615

1716
from traitlets import Any, Dict, List, default
@@ -229,6 +228,7 @@ def shebang(self, line, cell):
229228
"""
230229
import asyncio
231230
import asyncio.exceptions
231+
from subprocess import CalledProcessError
232232

233233
# Create the event loop in which to run script magics
234234
# this operates on a background thread

0 commit comments

Comments
 (0)