fix: lower ITextDocument error log to debugWarning for UnidentifiedEdit controls#20449
fix: lower ITextDocument error log to debugWarning for UnidentifiedEdit controls#20449Mubashir78 wants to merge 8 commits into
Conversation
|
Hi. You have unrelated commits here, e.g. from (#20159). |
…oid OSError log Fixes nvaccess#20428 When editAPIVersion is -1 (UnidentifiedEdit), _get_TextInfo attempts to use ITextDocumentTextInfo because the guard checked != 0. Changing to > 0 correctly excludes -1 as well, falling back to EditTextInfo without ever calling AccessibleObjectFromWindow (which would raise OSError). Also replace WindowsError with OSError in _get_ITextDocumentObject's except clause, since WindowsError is an alias for OSError on Python 3.3+ and may be removed in future Python versions.
68ab3c9 to
131caf2
Compare
|
Thanks, rebased onto master. |
|
Hi - please read our contributing guidelines and fill out the PR template. I've added it back to the PR for you. |
|
Thanks for the guidance. I've filled out the PR template and added changelog entries under Changes for Developers. Marked as ready for review. |
|
@Mubashir78 you write:
Where did you find an application or a situation where editAPIVersion is -1? Can you be more specific? It's worth noting that @SaschaCowley's question in #20428 (comment) has not yet been answered. @seanbudd I'd recommend to wait to clarify which real life use case we are trying to solve here before merging; more, this would allow to add an appropriate change log item mentioning #20428. |
|
Thanks for the review, @CyrilleB79. The editAPIVersion -1 case comes from UnidentifiedEdit (source/NVDAObjects/window/edit.py:1119), which is used when NVDA encounters an edit control whose API version cannot be determined. This happens in the window tree walk in NVDAObjects/window/init.py where UnidentifiedEdit is appended to the class list as a fallback. Since the code was using != 0 instead of > 0 before my fix, any unrecognized edit control hitting UnidentifiedEdit would attempt to use ITextDocumentTextInfo and log an OSError during the failing AccessibleObjectFromWindow call. I do not have a specific application to reproduce this, but the bug is clear from the code -- the != 0 guard is incorrect for a tri-state value where -1 means unknown. The fix is a defensive correctness improvement regardless of visible user impact. |
|
If you have no specific application to test this, my questions still stand:
|
The real-life application is ApprentiClavier 1.10 by Emmanuel Drouet (reported in #19245). The error was logged when pressing Enter repeatedly in that software.
Launch ApprentiClavier 1.10 and press Enter several times with NVDA debug logging enabled. Check the log for: Alternatively, as the original issue reporter noted in #20428, you can set |
|
Thanks for these additional details. This opens some more questions, as asked in #19245 (comment). If this PR actually improves the user experience with Apprenti Clavier, restoring pre-2026.1 behavior, you should add a corresponding change log item describing it, with a reference to #19245. If this PR only removes an error with no other visible effect, the question is: Do these error messages actually need to be filtered out? @seanbudd seems to say in #19245 (comment) that there is an issue with the Apprenti Clavier application; if it is confirmed, I do not understand why we would need to ignore error messages. |
|
@CyrilleB79 The guard |
|
@Mubashir78, so do you confirm that this PR does not change anything in the usage of ApprentiClavier? you have added a change log about an error no longer being logged. |
|
@CyrilleB79 Yes, no change to ApprentiClavier usage, only log cleanup. Understood on the changelog concern. I'm gonna wait for @seanbudd's opinion. |
|
Thanks for your patience @Mubashir78 with all my requests! Another point: In the same file, I find the following comment: This seems strange to me. Digging with @LeonarddeR could you please have a look at this PR and its impact? Thanks! |
|
@CyrilleB79 Its all good, your thoroughness made the PR better. Appreciate you taking the time to dig into the history and loop in @LeonarddeR 👍 |
|
@CyrilleB79 @LeonarddeR I looked deeper into the repo and found the docstring in This tells me the original intent was clear: try TOM and let RichEdit's error handling catch failures. The But in practice both paths end at I think the PR should be merged. The failing COM call is useless overhead and the log confuses users. Up to you both though. |
|
@LeonarddeR Actually yeah you are right. I reworked the PR per your suggestion. I reverted the guard back to |
|
Thanks for this. I wonder waht @CyrilleB79 and @seanbudd think about the changelog now. Errors in the log are silent on release builds unless explicitly opted in, so for non-power users, this is an invisible fix. |
|
This PR, as it is now, just changes a I have still the same opinion as what I wrote in #20449 (comment): this PR as it is now does not deserve a change log item since there won't be any visible change for users of stable releases. TTechnically, this PR fixes #19245 because it transforms an |
|
@CyrilleB79 here is what I found looking at the history: PR #8165 introduced In 2025.x (32-bit), In 2026.1 (64-bit migration), So the root cause is the 64-bit migration changing the COM error type from |
|
please update the PR description and title to reflect the changes |
|
Updated the PR title and description to: changing |
Fixes #20428
Link to issue number:
#20428
Summary of the issue:
When NVDA encounters an edit control whose API version cannot be determined (UnidentifiedEdit, editAPIVersion = -1),
_get_ITextDocumentObjectattempts to retrieve a TOM interface viaAccessibleObjectFromWindow. When this fails (e.g. for custom edit controls in apps like ApprentiClavier), anOSErroris logged atlog.errorlevel, producing a visible ERROR entry in the log.Description of user facing changes:
No user-facing changes. The error is only visible in debug logs.
Description of developer facing changes:
Changed
log.errortolog.debugWarninginEdit._get_ITextDocumentObjectso that the expected failure to retrieve TOM on non-TOM edit controls is logged at debug level instead of error level.Description of development approach:
The
editAPIVersion != 0guard is preserved so thatUnidentifiedEdit(which setseditAPIVersion = -1) still attempts TOM retrieval as designed. The only change is the log severity:error→debugWarning, since the TOM retrieval failure is an expected condition for these controls and has no diagnostic value at error level.Testing strategy:
Manual testing: verified that the OSError no longer appears at ERROR level in the NVDA log when interacting with edit fields where TOM is unavailable. The message now appears at DEBUGWARNING level when debug logging is enabled.
Known issues with pull request:
None.
Code Review Checklist: