From 3568f940f614b8a2389c3c56bdbf517f9ad6f88c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Andr=C3=A9s=20Margffoy=20Tuay?= Date: Tue, 31 Aug 2021 17:44:01 -0500 Subject: [PATCH] Prevent non-existing action removal --- spyder/api/widgets/menus.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/spyder/api/widgets/menus.py b/spyder/api/widgets/menus.py index 8b866c8ba93..79362f2ebe1 100644 --- a/spyder/api/widgets/menus.py +++ b/spyder/api/widgets/menus.py @@ -169,7 +169,15 @@ def add_action(self: T, action: Union[SpyderAction, T], def remove_action(self, item_id: str): if item_id in self._actions_map: action = self._actions_map.pop(item_id) - self._actions.remove(action) + position = None + + for i, (_, act) in enumerate(self._actions): + if act == action: + position = i + break + + if position is not None: + self._actions.pop(position) def get_title(self): """