Skip to content

Test non-paths in dunder path failing on Python 3.13 #318

Closed
@jaraco

Description

@jaraco
_______________ OpenNamespaceTests.test_non_paths_in_dunder_path _______________

self = <importlib_resources.tests.test_files.OpenNamespaceTests testMethod=test_non_paths_in_dunder_path>

    def test_non_paths_in_dunder_path(self):
        """
        Non-path items in a namespace package's ``__path__`` are ignored.
    
        As reported in python/importlib_resources#311, some tools
        like Setuptools, when creating editable packages, will inject
        non-paths into a namespace package's ``__path__``, a
        sentinel like
        ``__editable__.sample_namespace-1.0.finder.__path_hook__``
        to cause the ``PathEntryFinder`` to be called when searching
        for packages. In that case, resources should still be loadable.
        """
        import namespacedata01
    
        namespacedata01.__path__.append(
            '__editable__.sample_namespace-1.0.finder.__path_hook__'
        )
    
>       resources.files(namespacedata01)

importlib_resources/tests/test_files.py:81: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
importlib_resources/_common.py:46: in wrapper
    return func(anchor)
importlib_resources/_common.py:56: in files
    return from_package(resolve(anchor))
importlib_resources/_common.py:117: in from_package
    reader = spec.loader.get_resource_reader(spec.name)
importlib_resources/future/adapters.py:64: in get_resource_reader
    _skip_degenerate(_block_standard(super().get_resource_reader)(name))
importlib_resources/future/adapters.py:22: in wrapper
    reader = reader_getter(*args, **kwargs)
importlib_resources/_adapters.py:29: in get_resource_reader
    return CompatibilityFiles(self.spec)._native()
importlib_resources/_adapters.py:153: in _native
    reader = self._reader
importlib_resources/_adapters.py:147: in _reader
    return self.spec.loader.get_resource_reader(self.spec.name)
<frozen importlib._bootstrap_external>:1452: in get_resource_reader
    ???
/opt/hostedtoolcache/Python/3.13.0-rc.2/x64/lib/python3.13/importlib/resources/readers.py:136: in __init__
    self.path = MultiplexedPath(*map(self._resolve, namespace_path))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'importlib.resources.readers.NamespaceReader'>
path_str = '__editable__.sample_namespace-1.0.finder.__path_hook__'

    @classmethod
    def _resolve(cls, path_str) -> abc.Traversable:
        r"""
        Given an item from a namespace path, resolve it to a Traversable.
    
        path_str might be a directory on the filesystem or a path to a
        zipfile plus the path within the zipfile, e.g. ``/foo/bar`` or
        ``/foo/baz.zip/inner_dir`` or ``foo\baz.zip\inner_dir\sub``.
        """
>       (dir,) = (cand for cand in cls._candidate_paths(path_str) if cand.is_dir())
E       ValueError: not enough values to unpack (expected 1, got 0)

/opt/hostedtoolcache/Python/3.13.0-rc.2/x64/lib/python3.13/importlib/resources/readers.py:147: ValueError

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions