Steps to reproduce:
- Install an add-on which imports
gui in installTasks at the module level, such as Report passwords
- Try to reinstall it.
Actual behavior:
NVDA fails to restart properly and the following is in the log:
CRITICAL - __main__ (14:54:55.813) - MainThread (8104):
core failure
Traceback (most recent call last):
File "nvda.pyw", line 266, in <module>
core.main()
File "core.py", line 351, in main
import speech
File "speech\__init__.py", line 7, in <module>
from .speech import (
File "speech\speech.py", line 16, in <module>
import api
File "api.py", line 12, in <module>
import review
File "review.py", line 10, in <module>
from NVDAObjects import NVDAObject, NVDAObjectTextInfo
File "NVDAObjects\__init__.py", line 18, in <module>
import eventHandler
File "eventHandler.py", line 16, in <module>
import treeInterceptorHandler
File "treeInterceptorHandler.py", line 11, in <module>
import documentBase
File "documentBase.py", line 7, in <module>
from scriptHandler import isScriptWaiting
File "scriptHandler.py", line 13, in <module>
from speech import sayAll
File "speech\sayAll.py", line 11, in <module>
from .speech import (
ImportError: cannot import name 'speak' from 'speech.speech' (D:\my_repos\nvda\source\speech\speech.py)
Expected behavior:
NVDA should restart properly.
System configuration
NVDA installed/portable/running from source:
From sources
NVDA version:
Latest master as of May 11-th
Windows version:
Windows 7 X64
Name and version of other software in use when reproducing the issue:
None
Other information about your system:
Other questions
Does the issue still occur after restarting your computer?
Yes
Have you tried any other versions of NVDA? If so, please report their behaviors.
Yes - this has been introduced by #12251 and reverting this PR fixes the problem.
If add-ons are disabled, is your problem still occurring?
No but this issue is about NVDA's interaction with add-ons.
Does the issue still occur after you run the COM Registration Fixing Tool in NVDA's tools menu?
Not tried
Possible solutions:
I've investigated the problem and see three possible ways in which this can be fixed:
- By refactoring
gui so that most of the code which is currently in gui\__init__.py is moved to smaller files. This is unlikely to be done before 2021.1 and given that it should be preferably done in stages I'll create a new issue to discuss the best way to go about this.
- By converting
speech\sayAll to a package so that main file contains only function needed to initialize it and the rest including imports from speech are moved to a separate files.
- The smallest fix in terms of code would be to import
speech lazily in the ui module and move gui.IndeterminateProgressDialog to a separate file in the gui which would make sure that speech is not imported there at the module level.
cc @seanbudd I'm happy to work on this assuming you're happy with one of my proposals above / can suggest a better alternative.
Steps to reproduce:
guiin installTasks at the module level, such as Report passwordsActual behavior:
NVDA fails to restart properly and the following is in the log:
Expected behavior:
NVDA should restart properly.
System configuration
NVDA installed/portable/running from source:
From sources
NVDA version:
Latest master as of May 11-th
Windows version:
Windows 7 X64
Name and version of other software in use when reproducing the issue:
None
Other information about your system:
Other questions
Does the issue still occur after restarting your computer?
Yes
Have you tried any other versions of NVDA? If so, please report their behaviors.
Yes - this has been introduced by #12251 and reverting this PR fixes the problem.
If add-ons are disabled, is your problem still occurring?
No but this issue is about NVDA's interaction with add-ons.
Does the issue still occur after you run the COM Registration Fixing Tool in NVDA's tools menu?
Not tried
Possible solutions:
I've investigated the problem and see three possible ways in which this can be fixed:
guiso that most of the code which is currently ingui\__init__.pyis moved to smaller files. This is unlikely to be done before 2021.1 and given that it should be preferably done in stages I'll create a new issue to discuss the best way to go about this.speech\sayAllto a package so that main file contains only function needed to initialize it and the rest including imports from speech are moved to a separate files.speechlazily in theuimodule and movegui.IndeterminateProgressDialogto a separate file in the gui which would make sure thatspeechis not imported there at the module level.cc @seanbudd I'm happy to work on this assuming you're happy with one of my proposals above / can suggest a better alternative.