From 35a68d3f24ee9cc5d8f75be46b6921c7584c9413 Mon Sep 17 00:00:00 2001 From: dalthviz <16781833+dalthviz@users.noreply.github.com> Date: Tue, 25 Feb 2025 13:19:53 -0500 Subject: [PATCH 1/2] Variable Explorer: Catch TypeError when loading a .spydata file --- .../plugins/variableexplorer/widgets/namespacebrowser.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spyder/plugins/variableexplorer/widgets/namespacebrowser.py b/spyder/plugins/variableexplorer/widgets/namespacebrowser.py index 18e60bacaf8..68659817e1a 100644 --- a/spyder/plugins/variableexplorer/widgets/namespacebrowser.py +++ b/spyder/plugins/variableexplorer/widgets/namespacebrowser.py @@ -381,6 +381,14 @@ def load_data(self, filename, ext): "

{extensions}").format( extensions=', '.join(IMPORT_EXT)) return msg + except TypeError: + msg = _("Spyder is unable to open the file " + "you're trying to load. This could be caused due to a " + "difference between the packages versions used to create " + "the data and the versions installed with the currently " + "selected interpreter. Please check the packages versions " + "used to create the data and their compatibility with the " + "packages versions installed.
") except (UnpicklingError, RuntimeError, CommError): return None From 462ada40112ca762127b7be7a1e1a653127ab573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Althviz=20Mor=C3=A9?= <16781833+dalthviz@users.noreply.github.com> Date: Wed, 26 Feb 2025 13:29:37 -0500 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Carlos Cordoba --- .../variableexplorer/widgets/namespacebrowser.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/spyder/plugins/variableexplorer/widgets/namespacebrowser.py b/spyder/plugins/variableexplorer/widgets/namespacebrowser.py index 68659817e1a..b7505b9e33e 100644 --- a/spyder/plugins/variableexplorer/widgets/namespacebrowser.py +++ b/spyder/plugins/variableexplorer/widgets/namespacebrowser.py @@ -382,13 +382,14 @@ def load_data(self, filename, ext): extensions=', '.join(IMPORT_EXT)) return msg except TypeError: - msg = _("Spyder is unable to open the file " - "you're trying to load. This could be caused due to a " - "difference between the packages versions used to create " - "the data and the versions installed with the currently " - "selected interpreter. Please check the packages versions " - "used to create the data and their compatibility with the " - "packages versions installed.
") + msg = _( + "Spyder is unable to open the file you're trying to load. " + "This could be caused due to a difference between the package " + "versions used when you saved this spydata file and the ones " + "installed in the current environment. Please check the " + "compatibility between them (e.g. that you're using Numpy 2.x " + "in both environments).
" + ) except (UnpicklingError, RuntimeError, CommError): return None