From da811c064e09c53a8b243acd8567a9060fe6ca14 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sun, 23 Jun 2019 20:59:01 -0700 Subject: [PATCH 1/2] App module handler/does app mod exists: catch attribute error and assume there is no app module for desktop object if invokved from system tests in Python 3. Re #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. --- source/appModuleHandler.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/appModuleHandler.py b/source/appModuleHandler.py index e45bab88b4b..8eb16d2b9d9 100644 --- a/source/appModuleHandler.py +++ b/source/appModuleHandler.py @@ -153,7 +153,11 @@ def cleanup(): log.exception("Error terminating app module %r" % deadMod) 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: + return any(importer.find_module("appModules.%s" % name) for importer in _importers) + except AttributeError: + return False def fetchAppModule(processID,appName): """Returns an appModule found in the appModules directory, for the given application name. From b94925b18585c320f715b3309c777af14b3b5890 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Mon, 24 Jun 2019 19:06:53 -0700 Subject: [PATCH 2/2] App module handler/review actions: return early if importers list is not set. Re #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. --- source/appModuleHandler.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source/appModuleHandler.py b/source/appModuleHandler.py index 8eb16d2b9d9..e1de5b285d5 100644 --- a/source/appModuleHandler.py +++ b/source/appModuleHandler.py @@ -154,10 +154,9 @@ def cleanup(): def doesAppModuleExist(name): # #9797: when invoked from system tests, importers list isn't initialized (attribute error on a None object), thus assume no app module exists. - try: - return any(importer.find_module("appModules.%s" % name) for importer in _importers) - except AttributeError: + if _importers is None: return False + return any(importer.find_module("appModules.%s" % name) for importer in _importers) def fetchAppModule(processID,appName): """Returns an appModule found in the appModules directory, for the given application name.