Make Python console opening more robust (#17392)
Closes #17391
Summary of the issue:
When opening Python console with NVDA+control+Z, NVDA initialize snapshot variables. If an error occurs during the initialization of these variables, the console cannot open.
Description of user facing changes
The Python console will not fail to open anymore in case an error occurs while retrieving snapshot variables. If an exception occurs while retrieving a snapshot variable, this variable is set to None.
Note: I have imagined to display an error dialog if one or more variable cannot be retrieved successfully, but:
I have not been able to implement one. My trial lead to a not vocalized dialog, probably because run from the main thread instead of wx one.
I also wonder if there are side effect having a dialog here.
So I'd like to discuss this point before choosing investigating how to implement this design if you agree.
Description of development approach
For each snapshot variable, catch any exception that can occur during its retrieval and initialize the variable to None if retrieval has failed. Also log the corresponding error.
Note: I have added one more #noqa E402. I am tempted to remove all of them but have not done so because I do not know why they have been added in the first place.