App module handler/does app mod exists: return false when called before imports are initialized #9800
Conversation
…ume there is no app module for desktop object if invokved from system tests in Python 3. Re nvaccess#9797. When invoked from system tests under Python 3, app module handler will not be initialized, leaving importers (a private list) as None. By the time does app module exists function is called, this will return an attribute error. Thus return False if this happens.
| def doesAppModuleExist(name): | ||
| return any(importer.find_module("appModules.%s" % name) for importer in _importers) | ||
| # #9797: when invoked from system tests, importers list isn't initialized (attribute error on a None object), thus assume no app module exists. | ||
| try: |
There was a problem hiding this comment.
I think I would prefer just to check if _importers is None and return False, rather than letting it knowingly fail.
Though I'd like to also understand why systemTestSpy actually causes doesAppModule exist to be called? can you provide an example traceback on the issue?
|
Hi, Traceback: DEBUG - core.main (07:55:15.904): Thanks. |
…not set. Re nvaccess#9797. Reviewed by Mick Curran (NV Access): instead of using a try block, let NVDA say there is no app module if importers list isn't set, seen when invoking this function from system tests.
|
When I reviewed this I assumed it was _importers that was none. However, it is actually that _importers contains None as one of its items. |
Link to issue number:
Fixes #9797
Summary of the issue:
Attribute error is thrown if doesAppModuleExist function is invoked from system tests in Python 3.
Description of how this pull request fixes the issue:
When invoked from system tests under Python 3, app module handler will not be initialized, leaving importers (a private list) as None. By the time does app module exists function is called, this will return an attribute error. Thus return False if this happens.
Testing performed:
Tested with Python 2 and 3 source copies.
Known issues with pull request:
None
Change log entry:
None
Additional context:
This PR is part of an overall PR series on system tests.
Thanks.