Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable logging for python dependencies, particularly comtypes #10393

merged 5 commits into from Oct 21, 2019


Copy link

Link to issue number:

Related to #10247
Comtypes issue enthought/comtypes#192

Summary of the issue:

Some of our dependencies, particularly comtypes, have built in logging. However, logging data from these dependencies is ignored, as the NVDA logfile handler is set on the NVDA logger, not on the root logger of all loggers.

Description of how this pull request fixes the issue:

This pr registers our logHandler to the root logger. This means that python modules that use python's logging facility (not the NVDA specific one) are still able to log their information to the NVDA log.

The NVDA log level is also applied to the root logger, but only if it is warning or higher. This is because warnings or errors logged by dependencies like comtypes are certainly very interesting to know, though we want to avoid comtypes debug information leaking into our log when our log level is debug.

Testing performed:

Tested that comtypes.logger.error logs its data to the NVDA log and plays the NVDA error sound.

Known issues with pull request:

I initially started with a comtypes specific implementation that registered our log handler to the comtypes logger and was also able to log comtypes output at level debug. However, having comtypes log at the debug level is very verbose and, more importantly, can cause serious issues as some of its logging is re-entrant. Long story short, comtypes debug logging is not what we want.

Here is an example traceback generated when comtypes logging is set to debug. Strange enough, even though that traceback was sent to stderr, it didn't pop up in the log. I had to manually monkeypatch stderr to a text file in order for the traceback to be retrieved.

Change log entry:

  • Changes
    • Third party python packages included in NVDA, such as comtypes, now log their warnings and errors to the NVDA log.


This comment has been minimized.


This comment has been minimized.

Copy link
Collaborator Author

This is not in alpha yet.

Copy link

Brian1Gaff commented Oct 17, 2019 via email

@michaelDCurran michaelDCurran merged commit 60f068e into nvaccess:master Oct 21, 2019
@nvaccessAuto nvaccessAuto added this to the 2019.3 milestone Oct 21, 2019
michaelDCurran added a commit that referenced this pull request Oct 21, 2019
Copy link
Collaborator Author

This already proves to be helpful. When I open the Emoji panel in Windows 20:1 insider preview, i"m getting unhandled exceptions by our UIA event handler. I was already investing some resources in increasing UIA logging, so I fixed this in #10397 hopefully.

Copy link
Collaborator Author

Here is an example traceback:

ERROR - comtypes._comobject.call_without_this (08:41:05.355) - Dummy-5 (5384):
Exception in IUIAutomationFocusChangedEventHandler.HandleFocusChangedEvent implementation:
Traceback (most recent call last):
  File "comtypes\_comobject.pyc", line 147, in call_without_this
  File "_UIAHandler.pyc", line 328, in IUIAutomationFocusChangedEventHandler_HandleFocusChangedEvent
  File "comtypes\__init__.pyc", line 279, in __getattr__
  File "comtypesMonkeyPatches.pyc", line 26, in __call__
_ctypes.COMError: (-2147220991, 'Een gebeurtenis kan geen van de abonnees aanroepen', (None, None, None, 0, None))

In my opinion, we should catch these in NVDA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

4 participants