SG-40807 Fix raise FileNotFoundError#1088
Open
carlos-villavicencio-adsk wants to merge 2 commits intomasterfrom
Open
SG-40807 Fix raise FileNotFoundError#1088carlos-villavicencio-adsk wants to merge 2 commits intomasterfrom
FileNotFoundError#1088carlos-villavicencio-adsk wants to merge 2 commits intomasterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1088 +/- ##
==========================================
+ Coverage 79.40% 79.42% +0.02%
==========================================
Files 198 198
Lines 20738 20744 +6
==========================================
+ Hits 16466 16475 +9
+ Misses 4272 4269 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root Cause Analysis
This seems to be a non-backwards-compatible regression introduced on #1047. The issue is in import_handler.py's
find_specmethod (lines 278-296). When a module likeQtPrintSupportis requested from sgtk.platform.qt5:os.path.isdir(.../qt5/QtPrintSupport)returnsFalse(no such directory)SourceFileLoaderis created pointing to.../qt5/QtPrintSupport.py— this file doesn't exist, butSourceFileLoaderdoesn't validate at creation timespec_from_loader()also doesn't validate — no exception is raisedfind_specreturns a valid-looking spec, claiming it "found" the moduleSourceFileLoaderto execute the moduleSourceFileLoader.exec_module()tries to read the non-existent file →FileNotFoundErrorThe old imp-based code never had this problem because
imp.find_module()would raiseImportErrorimmediately if the file wasn't found.What happens with the fix:
CoreImportHandler.find_spec('sgtk.platform.qt5.QtPrintSupport', ...)sgtk.platform.qt5fromsys.modulesand gets its__path__module_file = .../qt5/QtPrintSupport.pyos.path.isfile(module_file)→ False → returns NonePathFinderetc.) — none findQtPrintSupporteither_find_and_load_unlockedgetsspec = None→ raisesModuleNotFoundError(subclass ofImportError)So the customer's
except ImportError:block will correctly catch the error again, just like before the imp → importlib migration.