From 166ed1fab36067718d9e31edbc4d86963bc480ff Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Thu, 27 May 2021 10:28:26 -0500 Subject: [PATCH] Editor: Catch an error when restoring files on Windows --- spyder/plugins/editor/widgets/editor.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/spyder/plugins/editor/widgets/editor.py b/spyder/plugins/editor/widgets/editor.py index 1a556c6062c..17327a36970 100644 --- a/spyder/plugins/editor/widgets/editor.py +++ b/spyder/plugins/editor/widgets/editor.py @@ -1504,7 +1504,15 @@ def has_filename(self, filename): def set_current_filename(self, filename, focus=True): """Set current filename and return the associated editor instance.""" - index = self.has_filename(filename) + # This is necessary to catch an error on Windows for files in a + # directory junction pointing to a symlink whose target is on a + # network drive that is unavailable at startup. + # Fixes spyder-ide/spyder#15714 + try: + index = self.has_filename(filename) + except FileNotFoundError: + index = None + if index is not None: if focus: self.set_stack_index(index)