Skip to content

Python 3 foundation: syntax compatibility for extensionPoints.util and others #8590

@josephsl

Description

@josephsl

Hi,

Most of the template below does not apply, although some minor points do.

This issue is based on #7105 and serves as a venue for discussing concrete implementations. For this one, syntax compatibility should be discussed.

Description:

When loading a file that is part of a package, Python 2.7 would happily accept the import statement of the form:

from foo import spam, eggs, ...

But Python3 prefers:

from .foo import spam, eggs, ...

Possibly because of prevalence of absolute imports. So far, this was observed with extensionPoints.util, but I'm sure this kind of syntax compatibility problem exists in other modules.

Steps to reproduce:

On Python 2.7 and 3.7, do:

  1. Create a package with several files and an init.py file.
  2. In init module, try writing and running the following statement via Python 2.7 and 3.7:

from fileInPackage import something

Actual behavior:

Python 3 throws import error.

Expected behavior:

Both Python 2 and 3 imports specified modules.

System configuration:

NVDA Installed/portable/running from source:

Not applicable, as this is Python 3 transition/research/foundation discussion.

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.15, 3.7.0

Other information about your system:

None

Other questions:

Does the issue still occur after restarting your PC?

N/A

Have you tried any other versions of NVDA?

N/A

Possible solution:

I propose standardizing on absolute import statement (Python 3 version) provided that it works in Python 2 as well.

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