Repository: nvaccess/nvda

Issue:
Post-speech gen refactor - AttributeError: speechDictHandler has no attribute "ENTRY_TYPE_ANYWHERE"
Hi,

Exhausted possible routes apart from either something with my add-ons or a regression:

### Steps to reproduce:
To do this, prepare two NVDA installers: alpha.20015 and alpha.20026, and latest Resource Monitor add-on (or any add-on that comes with installTasks.py):

1. Install alpha.20015.
2. Restart NVDA and install Resource Monitor add-on.
3. Restart NVDA if prmopted.
4. Install alpha.20026.
5. Instlal Resource Monitor add-on agaig.
6. Restart if prompted.

### Actual behavior:
The following traceback is recorded when NVDA restarts after installing add-ons:

```
core failure
Traceback (most recent call last):
  File "nvda.pyw", line 215, in <module>
  File "core.pyc", line 265, in main
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "speechDictHandler\__init__.pyc", line 12, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "api.pyc", line 12, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "review.pyc", line 10, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "NVDAObjects\__init__.pyc", line 16, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "eventHandler.pyc", line 12, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "treeInterceptorHandler.pyc", line 10, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "documentBase.pyc", line 7, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "scriptHandler.pyc", line 20, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "braille.pyc", line 21, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "gui\__init__.pyc", line 28, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "gui\settingsDialogs.pyc", line 2510, in <module>
  File "gui\settingsDialogs.pyc", line 2513, in DictionaryEntryDialog
AttributeError: module 'speechDictHandler' has no attribute 'ENTRY_TYPE_ANYWHERE'
```

### Expected behavior:
NO errors.

### System configuration
#### NVDA installed/portable/running from source:
Installed

#### NVDA version:
alpha.20015, alpha.20026

#### Windows version:
Windows 10 Version 2004 (build 19041.208)

#### Name and version of other software in use when reproducing the issue:
None

#### Other information about your system:
None

### 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.
Beta.20025 exhibits the same issue, earlier versions (including 2019.3.1) do not.

#### If addons are disabled, is your problem still occuring?
Yes.

#### Did you try to run the COM registry fixing tool in NVDA menu / tools?
Not applicable.

### Possible cause:
Speech function type refactor, as the problems began after instlaling alpha/beta snapshots with this change. It appears if an add-on with installTasks.py (with onInstall function defined) is installed and when NVDA restarts to complete add-on install, it shows the above traceback. Testing a build of Resource Monitor with installTasks module removed eliminates this issue.

Thanks.


Discussion:
The full name for these two builds is `alpha-20015,56a62097` and `alpha-20026,16ec967e`. The second part is helpful because it is the SHA for the commit.

They come from the following respective commits:
1. [`alpha-20015,56a62097`](https://github.com/nvaccess/nvda/commit/56a6209704ca80723d11e038647f9761c84617a8)
   - This commit just update the changes file
1. [`alpha-20026,16ec967e`](https://github.com/nvaccess/nvda/commit/16ec967e3dcadb77d79862fd6dcb3c4868247260)
   - This merges in beta

The diff between theses commits can be seen with [`git diff 56a62097..16ec967e`](https://github.com/nvaccess/nvda/compare/56a6209704ca80723d11e038647f9761c84617a8..16ec967e3dcadb77d79862fd6dcb3c4868247260)

By far the most likely candidate changes come from commit https://github.com/nvaccess/nvda/commit/78b85fa779e6e8788c1aedc0e7bde3cbb51bea9d merged from PR #11040

That said, looking through that diff there isn't anything obvious!

> Testing a build of Resource Monitor with `installTasks` module removed eliminates this issue.

Which makes me wonder what is in the `installTasks` module.
I'll assume the `installTasks` module on master exhibits the problem: https://github.com/josephsl/resourceMonitor/blob/master/addon/installTasks.py
I'm a little confused by the initial description. I assumed this issue was not happening in `alpha.20015` and then was in `alpha-20026` but you don't explicitly say that. Can you confirm please?

Can you reproduce with a source copy of NVDA? If so, you could roll back the changes in commit 78b85fa (#11040) chunk by chunk and see when the error is introduced. 
Hi, this issue doesn’t occur in source code copy as restarting it from NVDA itself after installing add-ons isn’t working, and yes, this issue doesn’t appear in older NVDA alpha build. The only thing the install tasks in the add-on does is check Windows version for compatibility purposes and displays a dialog if it isn’t compatible. I’ll do some more investigations. Thanks.

 

From: Reef Turner <notifications@github.com> 
Sent: Friday, April 24, 2020 7:13 AM
To: nvaccess/nvda <nvda@noreply.github.com>
Cc: Joseph Lee <joseph.lee22590@gmail.com>; Author <author@noreply.github.com>
Subject: Re: [nvaccess/nvda] Post-speech gen refactor - AttributeError: speechDictHandler has no attribute "ENTRY_TYPE_ANYWHERE" (#11052)

 

I'm a little confused by the initial description. I assumed this issue was not happening in alpha.20015 and then was in alpha-20026 but you don't explicitly say that. Can you confirm please?

Can you reproduce with a source copy of NVDA? If so, you could roll back the changes in commit  <https://github.com/nvaccess/nvda/commit/78b85fa779e6e8788c1aedc0e7bde3cbb51bea9d> 78b85fa (#11040 <https://github.com/nvaccess/nvda/pull/11040> ) chunk by chunk and see when the error is introduced.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <https://github.com/nvaccess/nvda/issues/11052#issuecomment-619035172> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AB4AXEHWVDK55DMVQ7XGAOTROGM55ANCNFSM4MPZTE6A> .


Hi,

Based on source-based portable copy (scons dist), I can confirm that the commit mentioned might be a highly likely one:

1. Ran scons dist from beta branch and renamed the resulting folder once generated.
2. Checked out a different branch and reverted the commit mentioned.
3. Ran scons dist.
4. Installed Resource Monitor multiple times on both versions.

The beta branch raises AttributeError, whereas the reverted branch does not. I'll look into individual fragments to see what's up.

Thanks.
Hi,

Found it: say all handler might be it.

Tests:

1. Build a portable copy of NVDA with speech generator refactor removed.
2. Run the generated portable copy and install add-ons.
3. Delete the portable copy.
4. Copy say all handler from current beta.
5. Repeat steps 1 through 3.
6. Stash changes.
7. Copy speech module from beta.
8. Repeat steps 1 through 3.
9. Stash changes.
10. Pop the last two stashes 9saved in steps 6 and 9) so it resembles beta branch.
11. Repeat steps 1 through 3.

Results:

* Beta reverted: no error.
* Only say all handler added: error.
* Only speech module added: no error.
* Beta (both combined): error.

Thanks.
Hi,

Traced to importing generator when NVDA isn't fully initialized. I'll send a PR that will import this specific attribute just before the flatten list iterator is called. An alternative is just using the attribute from speech module without direclty importing it.

Thanks.

Resolving patch:
diff --git a/source/sayAllHandler.py b/source/sayAllHandler.py
--- a/source/sayAllHandler.py
+++ b/source/sayAllHandler.py
@@ -2,9 +2,9 @@
 # Copyright (C) 2006-2017 NV Access Limited
 # This file may be used under the terms of the GNU General Public License, version 2 or later.
 # For more details see: https://www.gnu.org/licenses/gpl-2.0.html
+
 import weakref
 import speech
-from speech import _flattenNestedSequences
 import synthDriverHandler
 from logHandler import log
 import config
@@ -169,7 +169,7 @@ def _onLineReached(obj=self.reader.obj, state=state):
 			reason=controlTypes.REASON_SAYALL,
 			useCache=state
 		)
-		seq = list(_flattenNestedSequences(speechGen))
+		seq = list(speech._flattenNestedSequences(speechGen))
 		seq.insert(0, cb)
 		# Speak the speech sequence.
 		spoke = speech.speakWithoutPauses(seq)


Test patch: