From 7a33e1b9c268dae5e48ddd5a0ac4fd0be9609925 Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Tue, 19 Sep 2023 11:15:36 +0200 Subject: [PATCH] Backport PR #14169: Set instance on singleton configurable when created via constructor. --- IPython/terminal/embed.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/IPython/terminal/embed.py b/IPython/terminal/embed.py index ce5ee01ff18..59fa6106776 100644 --- a/IPython/terminal/embed.py +++ b/IPython/terminal/embed.py @@ -158,6 +158,12 @@ def __init__(self, **kw): assert ( "user_global_ns" not in kw ), "Key word argument `user_global_ns` has been replaced by `user_module` since IPython 4.0." + # temporary fix for https://github.com/ipython/ipython/issues/14164 + cls = type(self) + if cls._instance is None: + for subclass in cls._walk_mro(): + subclass._instance = self + cls._instance = self clid = kw.pop('_init_location_id', None) if not clid: