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
Use importlib.util.find_spec when checking if the given appModule exists to workaround issues in find_module and for forward compatibility. #13853
Conversation
…sts to workaround issues in find_module and for forward compatibility.
@lukaszgo1 - the PR description is misleading, notably there is no bug with Python. Suggested changes: Summary of the issue:As mentioned in #13814 (comment) Description of development approachWhen checking if the given appModule exists, instead use |
Should this PR also remove the introduced change in #13814, which added the replacement of periods to underscores: https://github.com/nvaccess/nvda/blob/7e85396/source/appModuleHandler.py#L159-L164 |
This comment was marked as off-topic.
This comment was marked as off-topic.
Could you also consider changing the other usage of the deprecated nvda/source/addonHandler/__init__.py Line 486 in ca41d22
|
I'm not sure I agree - if the method responsible for checking if the given module exists returns
In our case the finders should be for the package
No, it should not. This change was introduced in #5323 and some add-ons may rely on it. We should not try to deprecate this behavior as that would make it unnecessarily difficult for add-on authors to target both old and new releases of NVDA. #13814 just moved the code to a different (more appropriate IMHO) place. It also has additional benefit namely that add-on authors can add app modules for hosting processes whose binaries contain dots in their names.
I'd rather do this in a follow up. |
I'd argue that the behaviour is documented in Without a confirmed/reported python bug, I'd rather be agnostic in the language here. To avoid bike shedding this PR, I'm going to update the description and merge as-is. Feel free to update / edit it further. |
note I have added that this behaviour is incorrect.
|
Link to issue number:
None, discussion in PR #13814
Summary of the issue:
As mentioned in #13814 (comment)
FileFinder.find_module
is deprecated.find_spec
is the recommended replacement method.As noted in #13814 (comment), using either
find_spec
orfind_module
withpkgutil.iter_importers
results in paths containing "." being incorrectly treated as python packages, causing #13813Description of development approach
Description of user facing changes
No user facing change
Description of development approach
When checking if the given appModule exists, instead use
importlib.util.find_spec
, which does not have the same problematic behaviour aspkgutil.iter_importers
.Testing strategy:
Known issues with pull request:
None known
Change log entries:
None needed - internal change
Code Review Checklist: