Fix-up of #13366: Replace dots with underscores before trying to check if the given App Module exists to work around bug in the Python import system#13814
Conversation
… Module exists to work around bug in the Python import system
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as outdated.
This comment was marked as outdated.
|
From reading Python importlib docs Can you test using I would test this but I am struggling to understand the Python bug described in the issue a summary. A minimal python sample would be helpful here. |
|
@lukaszgo1 I'm looking into using |
|
It appears that |
|
This doesn't appear to be a bug. Note the documentation from
|
…sts to workaround issues in find_module and for forward compatibility. (#13853) 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 or find_module with pkgutil.iter_importers results in paths containing "." being incorrectly treated as python packages, causing #13813 Description 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 as pkgutil.iter_importers.
Opened against beta since this fixes regression introduced during 2022.2 development cycle.
Link to issue number:
Fix-up of #13366
Fixes #13813
Summary of the issue:
As part of PR #13366 I've modified the code responsible for retrieving application name from process id so that it no longer tries to import an App Module for a hosting process if it does not exist. Unfortunately Python
find_Modulemethod seems to have a bug - it returns a module when the provided string contains dots and the file named exactly like the last segment of the provided name exists in the package. For example if you have module namedqqin the package, and you would like to check if the module named6.5.qqexistsTrueis returned even though there is no such module. I haven't yet tested how this behaves with more recent versions of Python nor opened an issue against them.Description of user facing changes
NVDA no longer fails to work in applications containing dots in their file names in cases where you have an App Module for an application named exactly like the last segment of the application name.
Description of development approach
Dots are normalized to underscores before checking if the given module exists. While we did this already before trying to import a standard App Module this has not been done before trying to get module for a hosting process.
Testing strategy:
Known issues with pull request:
None known
Change log entries:
None needed - unreleased regression.
Code Review Checklist: