Skip to content

App modules/aliases/Python 3: use relative import statement #8649

@josephsl

Description

@josephsl

Hi,

Another potential issue with Python 3 transition: app module aliases may raise import issues.

Steps to reproduce:

  1. Create a package of Python files (a folder) with several Python files inside.
  2. From one or more files inside this package, do "from anotherMod import something".

Actual behavior:

Python's import machinery gets confused regarding where the package lives.

Expected behavior:

Python should be able to load the correct package/file.

System configuration:

NVDA Installed/portable/running from source:

Not applicable

NVDA version:

Not applicable

Windows version:

Windows 10 Version 1803

Name and version of other software in use when reproducing the issue:

Python 2.7, 3.7

Other information about your system:

N/A

Other questions:

Does the issue still occur after restarting your PC?

Yes

Have you tried any other versions of NVDA?

N/A

Impact:

The import machinery issue is most prominent in app modules where several modules are aliases of one another (win32calc.py as an alias of calc.py, for instance). There are other modules where this issue arises, including extensionPoints and synthDrivers.espeak.

Solution:

As part of the pull request on Python 3 imports, a straightforward relative import will be used. This means changing "from someAlias import *" to "from .someAlias import *" in app modules and other modules where this problem occurs.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions