Python 3: Fix SAFE_SCRIPTS in lockapp appModule - #9884
Merged
Conversation
feerrenrut
approved these changes
Jul 9, 2019
feerrenrut
pushed a commit
that referenced
this pull request
Jul 11, 2019
Our Python 2 code contained some workarounds and code paths that are no longer necessary or confusing when on Python 3. 1. Most notably, this is related to functions with `*args` and `**kwargs` catch all handlers which also required a specific keyword argument. Once of these was part of the `hwIo` module and has already been removed in an earlier state. - Code where we pop a particular argument from `kwargs` now contains that argument as a keyword only argument in the signature of the function. 2. Furthermore, there was a workaround in the `gui` code to register support for the `cp65001` codec in Python 2, which is a known codec in Python 3. - This is removed 3. The `scriptHandler.script` decorator checked whether the decorated script was a routine. This also returned `True` for bound instance methods, and therefore no warning was raised when trying to decorate a bound instance method (which is unsupported). Now, such a warning will be raised. See also #9884 - When decorating a script, we now use `isinstance(script, types.FunctionType)` 4. `config.AggregatedSection` still had an `iteritems` method. - `config.AggregatedSection.iteritems` has been renamed to items.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Link to issue number:
Fixes #9883
Summary of the issue:
On the Windows 10 lock screen, invoked with Windows+L. The user copy of NVDA is still active. As the screen is locked, there is a set of safe scripts on the appmodule for the lock screen to make sure that the NVDA configuration isn't changed when on the lock screen. However, this SAFE_SCRIPTS set expected scripts on
globalCommands.GlobalCommandsto be unbound methods, so for every script, it took the__func__attribute on the unbound method to get to the actual function. In python 3 unbound methods are gone.Description of how this pull request fixes the issue:
SAFE_SCRIPTSnow just contains the raw scripts fromglobalCommands.GlobalCommands, which are now functions, no longer unbound methods. When comparing a bound script with theSAFE_SCRIPTS, we're dealing with a bound method and thus we still have to traverse up to the__func__attribute on the bound script. I added an explanatory comment for that.Testing performed:
Went to the NVDA lock screen. Made sure that unsafe scripts, such as NVDA+2 (enable/disable typed characters) does no longer work.
Known issues with pull request:
None
Change log entry:
None