-
-
Notifications
You must be signed in to change notification settings - Fork 702
Fixed a bug causing wrong deprecation warnings or errors. #14806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
See test results for failed build of commit a18e67891d |
86a682d
to
e622fe3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR @CyrilleB79 ! In fact this regressed in #14350 as follows:
- Before #14350 at the first import of
appModuleHandler
no additional packages were added to the path ofappModules
, so first index indeed represented the path of modules bundled in NVDA - Now code in scratchpad and in add-ons is added to the path before
appModuleHandler
is first imported, which means that first item in the path represents either the code in the scratchpad, or the first loaded add-on with appModules.
Given that relying on the order of imports turned out to be fragile I'd suggest to remove _CORE_APP_MODULES_PATH
, and just check if the module is a part of NVDA's core using logHandler.isPathExternalToNVDA
, which should be way more reliable. What do you think?
As an aside, I'm not sure if logHandler
is the best place for isPathExternalToNVDA
, but that is an issue for a different discussion perhaps.
Thanks @lukaszgo1 for the thorough investigation and the details. I have updated the initial description to link with the correct PR.
Well, I am not sure that this function is more robust. On my system the log messages emitted by core files are prefixed by "external" when run from source... On the contrary appModule import order is much less likely to be modified and I do not expect add-ons modifying Of course, a third solution (if any) retrieving the path of |
Suggested change to changelog wording:
NVDA will not log anymore inappropriate warnings or errors for deprecated appModules.
NVDA will no longer log inaccurate warnings or errors about deprecated
appModules.
|
Does this also hold true for add ons that give these messages? By which I
mean if I see blah blag command deprecated, use wotsit instead, is that
coming from nvda core code even though its generated in a line in an add on,
or is this nvda actually saying this won't work in the next version of the
compiler?
Take a look at Sound schemes add on for some examples in the log.
Brian
…--
***@***.***
Sent via blueyonder.(Virgin media)
Please address personal E-mail to:-
***@***.***, putting 'Brian Gaff'
in the display name field.
----- Original Message -----
From: "Cyrille Bougot" ***@***.***>
To: "nvaccess/nvda" ***@***.***>
Cc: "Subscribed" ***@***.***>
Sent: Friday, April 07, 2023 3:36 PM
Subject: [nvaccess/nvda] Fixed a bug causing wrong deprecation warnings or
errors. (PR #14806)
### Link to issue number:
None
Fix-up of #13366.
### Summary of the issue:
Running NVDA 2023.1 (and older), with add-ons and/or scratchpad enabled:
I get the following deprecation warnings:
* When opening start menu:
```
WARNING - appModuleHandler._warnDeprecatedAliasAppModule (15:49:46.531) -
MainThread (19688):
Importing appModules.searchapp is deprecated, instead import
appModules.searchui.
```
* When switching to Notepad++:
```
WARNING - appModuleHandler._warnDeprecatedAliasAppModule (15:50:26.621) -
MainThread (19688):
Importing appModules.notepad++ is deprecated, instead import
appModules.notepadPlusPlus.
```
And if I force errors on deprecated code by modifying
`NVDAState._allowDeprecatedAPI` to return False, I get errors instead.
This is not expected since these warnings/errors come from NVDA's core
code which should not (and actually does not) contain deprecated code.
### Description of user facing changes
No more wrong deprecation warnings/errors due to NVDA's core
appModules when opening start menu or switching to Notepad++
### Description of development approach
`appModules.__path__` contains the paths where NVDA has to search
appModules. It contains first the folder in the scratchpad, then the
folders in add-on containing appModules and finally the core appModule
folder. Thus we need to look at the last element of `appModules.__path__`,
not the first as it was done.
### Testing strategy:
* Test with add-ons and scratchpad that no deprecation warning nor error
appear anymore.
* Tested that the following call in the console still causes the warning
to be logged (upon first call):
`from appModules import searchapp`
Note: This was probably missed during #13366 test, maybe because it was
tested without add-on nor scratchpad.
### Known issues with pull request:
### Change log entries:
Bug fixes (or Changes for developers? Where should bugfixes impacting only
dev be listed?)
`NVDA will not log anymore inappropriate warnings or errors for deprecated
appModules.`
### Code Review Checklist:
- [x] Pull Request description:
- description is up to date
- change log entries
- [x] Testing:
- Unit tests
- System (end to end) tests
- Manual testing
- [x] API is compatible with existing add-ons.
- [x] Documentation:
- User Documentation
- Developer / Technical Documentation
- Context sensitive help for GUI changes
- [x] UX of all users considered:
- Speech
- Braille
- Low Vision
- Different web browsers
- Localization in other languages / culture than English
- [x] Security precautions taken.
You can view, comment on, or merge this pull request online at:
#14806
-- Commit Summary --
* Fixed a bug causing wrong deprecation warnings or errors.
-- File Changes --
M source/appModuleHandler.py (4)
-- Patch Links --
https://github.com/nvaccess/nvda/pull/14806.patch
https://github.com/nvaccess/nvda/pull/14806.diff
--
Reply to this email directly or view it on GitHub:
#14806
You are receiving this because you are subscribed to this thread.
Message ID: ***@***.***>
|
@XLTechie I had the feeling that my wording did not sound very well actually; many thanks for the English wording fix. |
Unless the add-on imports appModules from NVDA's core, it's unrelated. I do not know nor use Sound schemes add-on but IMO it's very unlikely that this PR changes anything. |
That's pretty unfortunate - I've assumed that even if someone appends to
This can be easily done with |
This is now implemented in #14812 |
Labelling this as blocked by #14812 and marking as draft |
I'm not sure why this is blocked by #14812 unless the solution for retrieving real path of core app modules, which I've proposed in this comment is considered inappropriate for some reason. |
Apologies @lukaszgo1 I misunderstood your comment. |
…comes from external code or not. (#14812) Discussion in #14806 Summary of the issue: When logging NVDA tries to determine if the logged message comes from its own code or from an add-on. In some cases it does so incorrectly. Case 1: Directory prepended to sys.path by an add-on Some add-ons have to modify sys.path to import additional libraries. NVDA's logHandler relied on the fact that the first entry in path represents the location of NVDA's source code. While add-on developers should really clean-up after themselves i.e. modify path only for as long as necessary to import additional libraries this is not something we can enforce. Initially observed by @CyrilleB79 for an add-on for ChatGPT. Case 2: Messages logged from add-ons installed in the default config for source copies By default configuration folder for source copies is placed next to NVDA sources, i.e. in the source folder. When determining if the path belongs to NVDA or not we used to check if the given path starts with NVDA's source folder which was true for the plugins in the user config even though the code was not a part of NVDA. Description of user facing changes This should affect only developers who inspect the log. Description of development approach When checking if the path is external or not we no longer rely on sys.path - rather the location of the logHandler is used to determine the true location of NVDA's source code. In addition if the path is beneath the current NVDA's config it is always marked as external.
Thanks @lukaszgo1, I have modified the code with your suggestion for more robustness. Your suggestion gives the path on installed version as well as on a version running from source. @seanbudd this PR is ready again. I have tested again as described in the initial description. |
Thanks @CyrilleB79 |
Link to issue number:
None
Fix-up of #14350.
Summary of the issue:
Running NVDA 2023.1 (and older), with add-ons and/or scratchpad enabled:
I get the following deprecation warnings:
And if I force errors on deprecated code by modifying
NVDAState._allowDeprecatedAPI
to return False, I get errors instead.This is not expected since these warnings/errors come from NVDA's core code which should not (and actually does not) contain deprecated code.
Description of user facing changes
No more wrong deprecation warnings/errors due to NVDA's core appModules when opening start menu or switching to Notepad++
Description of development approach
appModules.__path__
contains the paths where NVDA has to search appModules. It contains first the folder in the scratchpad, then the folders in add-on containing appModules and finally the core appModule folder. Thus we need to look at the last element ofappModules.__path__
, not the first as it was done.Testing strategy:
from appModules import searchapp
Note: This was probably missed during #13366 test, maybe because it was tested without add-on nor scratchpad.
Known issues with pull request:
Change log entries:
Bug fixes (or Changes for developers? Where should bugfixes impacting only dev be listed?)
NVDA will no longer log inaccurate warnings or errors about deprecated appModules. (#14806)
Code Review Checklist: