Fix-up of #9843: Fixed an error preventing a failed copy operation from being reported [NVDA 2020.4beta1] #11959
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR made against beta branch since the PR it is fixing is not yet part of a stable release.
Cc @feerrenrut
Link to issue number:
None
Fix-up of #9843.
Summary of the issue:
When using
api.copyToClip
with new argumentnotify=True
, if any call to the clipboard API fails, "Unable to copy" message should be reported since the merge of #9843. This is however not the case.It was discovered during my computer stress tests (for unrelated reasons). The stress tests consists in keeping NVDA+T pressed during a long time (30 seconds or one minute) in MS Word.
After a while, the clipboard is overflowed by API operations and become inaccessible. The following error is reported in the log:
As per #9843, "Unable to copy" should be reported in this case and no error should occur.
Description of how this pull request fixes the issue:
In
api.copyToClip
, caughtOSError
instead of unappropriatedctypes.WinError
which is a function.I have seen in NVDA code (probably Python 2 legacy code) that we use
WinError
in this case.Anyway, Python doc tells us to use
OSError
:In any case,
WinError
andOSError
are the same.Testing performed:
Tested with the same stress test that the failing copy is reported. Since many messages are reported and interrupted, I have heard only the beginning of the message that differs from the message reporting a successful copy. I have then checked this message in the log.
Known issues with pull request:
None
Change log entry:
Not needed since #9843 is not yet part of a stable release.
Cc @JulienCochuyt (author of #9843).