Skip to content

config.py._consider_importhook assumes SOURCES.txt uses platform-specific separator while it is not #2591

@throwable-one

Description

@throwable-one

From here: https://svn.python.org/projects/sandbox/trunk/setuptools/doc/formats.txt

The filenames always use / as a path separator, which must be
converted back to a platform-specific path whenever they are read.

My SOURCES.txt has / even on Windows.

Now loo0k at _pytest/config.py:1034

 metadata_files = 'RECORD', 'SOURCES.txt'

        package_files = (
            entry.split(',')[0]
            for entrypoint in pkg_resources.iter_entry_points('pytest11')
            for metadata in metadata_files
            for entry in entrypoint.dist._get_metadata(metadata)
        )

        for fn in package_files:
            is_simple_module = os.sep not in fn and fn.endswith('.py') # LOOK HERE !!!!
            is_package = fn.count(os.sep) == 1 and fn.endswith('__init__.py')
            if is_simple_module:
                module_name, ext = os.path.splitext(fn)
                hook.mark_rewrite(module_name)
            elif is_package:
                package_name = os.path.dirname(fn)
                hook.mark_rewrite(package_name)

os.sep should not be used here. It leads to errors like one module is considered to be is_simple_module on **nix, but not on Windows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueeasy issue that is friendly to new contributortype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions