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

Skip to content

Commit e8e4625

Browse files
committed
Raise proper exception on failed delattr.
This is needed by IPython 8.15 at shutdown (if _1 has been defined).
1 parent 8ff460d commit e8e4625

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

README.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,10 @@ When using Jedi autocompletion (the default if Jedi is installed as of IPython
9393
failure, because Jedi purposefully converts the global dict to a namespace
9494
object and looks up attributes using ``getattr_static``. Jedi can be disabled
9595
by adding ``c.Completer.use_jedi = False`` to the ``ipython_config.py`` file.
96+
97+
Changelog
98+
---------
99+
100+
next
101+
~~~~
102+
- Avoid erroring when exiting IPython≥8.15.

lib/ipython_autoimport.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,10 @@ def __setitem__(self, name, value):
199199

200200
def __delitem__(self, name):
201201
super().__delitem__(name)
202-
delattr(self._ipython.user_module, name)
202+
try:
203+
delattr(self._ipython.user_module, name)
204+
except AttributeError:
205+
raise KeyError(name)
203206

204207

205208
def _patch_magic(func):

0 commit comments

Comments
 (0)