Skip to content

Python 3: Fix SAFE_SCRIPTS in lockapp appModule - #9884

Merged
feerrenrut merged 1 commit into
nvaccess:threshold_py3_stagingfrom
LeonarddeR:i9883
Jul 9, 2019
Merged

Python 3: Fix SAFE_SCRIPTS in lockapp appModule#9884
feerrenrut merged 1 commit into
nvaccess:threshold_py3_stagingfrom
LeonarddeR:i9883

Conversation

@LeonarddeR

@LeonarddeR LeonarddeR commented Jul 6, 2019

Copy link
Copy Markdown
Collaborator

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.GlobalCommands to 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_SCRIPTS now just contains the raw scripts from globalCommands.GlobalCommands, which are now functions, no longer unbound methods. When comparing a bound script with the SAFE_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

@feerrenrut
feerrenrut merged commit 200a7a6 into nvaccess:threshold_py3_staging Jul 9, 2019
@nvaccessAuto nvaccessAuto added this to the 2019.3 milestone 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.
@LeonarddeR
LeonarddeR deleted the i9883 branch August 23, 2025 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants