Skip to content

Fix deprecation in security.py#14537

Merged
seanbudd merged 3 commits into
nvaccess:masterfrom
CyrilleB79:fixDeprecation
Jan 16, 2023
Merged

Fix deprecation in security.py#14537
seanbudd merged 3 commits into
nvaccess:masterfrom
CyrilleB79:fixDeprecation

Conversation

@CyrilleB79

@CyrilleB79 CyrilleB79 commented Jan 14, 2023

Copy link
Copy Markdown
Contributor

Link to issue number:

None

Summary of the issue:

When testing for deprecated code, the following message is found when importing something (even not deprecated) from security.py, e.g.:
from utils.security import post_sessionLockStateChanged

DEBUG - utils.security.__getattr__ (17:36:01.633) - MainThread (17584):
Deprecated __path__ imported while _allowDeprecatedAPI is False

Description of user facing changes

No change for users.

For developers, when deprecated functions are not allowed, removed irrelevant log messages, e.g. indicating that __path__ is deprecated.

Description of development approach

  • Fix made in the logic of utils.security.__getattr__ in order not to log a debug message for any missing variable in utils.security (e.g. __path__)
  • Removed the log.debug which did not seem useful in any case.
  • While checking at other deprecation management functions, moved the docstrings which were found not at the top of the functions.

Testing strategy:

Manual tests:
In the code, manually set _allowDeprecatedAPI to return False and run the following console commands:

# Check in the log that there is no related DEBUG message anymore when running the following command.
>>> from utils.security import post_sessionLockStateChanged

# Check that the following commands have an help message (docstring):
>>> help(winKernel.__getattr__)
>>> help(winUser.__getattr__)

Known issues with pull request:

None

Change log entries:

Not needed: fixing unreleased changes.

Code Review Checklist:

  • Pull Request description:
    • description is up to date
    • change log entries
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • API is compatible with existing add-ons.
  • Documentation:
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • Security precautions taken.

@seanbudd seanbudd added this to the 2023.1 milestone Jan 15, 2023
@seanbudd

Copy link
Copy Markdown
Member

Should this be marked as ready for review?

@CyrilleB79 CyrilleB79 marked this pull request as ready for review January 16, 2023 07:35
@CyrilleB79 CyrilleB79 requested a review from a team as a code owner January 16, 2023 07:35
@CyrilleB79 CyrilleB79 requested a review from seanbudd January 16, 2023 07:35

@seanbudd seanbudd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching all these, LGTM otherwise

Comment thread source/utils/security.py Outdated
@seanbudd seanbudd merged commit e460801 into nvaccess:master Jan 16, 2023
@CyrilleB79 CyrilleB79 deleted the fixDeprecation branch January 16, 2023 09:41
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.

2 participants