classification
Title: test_importlib failed on installed Python
Type: Stage: resolved
Components: Tests Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jaraco Nosy List: jaraco, pitrou, vstinner
Priority: normal Keywords: patch

Created on 2021-03-20 14:58 by vstinner, last changed 2021-03-22 09:01 by vstinner. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 24952 merged jaraco, 2021-03-20 21:59
Messages (12)
msg389160 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-03-20 14:58
Example on aarch64 Fedora Stable Clang Installed 3.x:
https://buildbot.python.org/all/#/builders/14/builds/804

======================================================================
ERROR: test_open_binary (test.test_importlib.test_open.OpenDiskNamespaceTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/test_open.py", line 67, in setUp
    from . import namespacedata01
ImportError: cannot import name 'namespacedata01' from 'test.test_importlib' (/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/__init__.py)

======================================================================
ERROR: test_open_binary_FileNotFoundError (test.test_importlib.test_open.OpenDiskNamespaceTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/test_open.py", line 67, in setUp
    from . import namespacedata01
ImportError: cannot import name 'namespacedata01' from 'test.test_importlib' (/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/__init__.py)

======================================================================
ERROR: test_open_text_FileNotFoundError (test.test_importlib.test_open.OpenDiskNamespaceTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/test_open.py", line 67, in setUp
    from . import namespacedata01
ImportError: cannot import name 'namespacedata01' from 'test.test_importlib' (/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/__init__.py)

======================================================================
ERROR: test_open_text_default_encoding (test.test_importlib.test_open.OpenDiskNamespaceTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/test_open.py", line 67, in setUp
    from . import namespacedata01
ImportError: cannot import name 'namespacedata01' from 'test.test_importlib' (/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/__init__.py)

======================================================================
ERROR: test_open_text_given_encoding (test.test_importlib.test_open.OpenDiskNamespaceTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/test_open.py", line 67, in setUp
    from . import namespacedata01
ImportError: cannot import name 'namespacedata01' from 'test.test_importlib' (/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/__init__.py)

======================================================================
ERROR: test_open_text_with_errors (test.test_importlib.test_open.OpenDiskNamespaceTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/test_open.py", line 67, in setUp
    from . import namespacedata01
ImportError: cannot import name 'namespacedata01' from 'test.test_importlib' (/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/__init__.py)

======================================================================
ERROR: test_is_dir (test.test_importlib.test_reader.MultiplexedPathTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/test_reader.py", line 48, in test_is_dir
    self.assertEqual(MultiplexedPath(self.folder).is_dir(), True)
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/importlib/readers.py", line 63, in __init__
    raise NotADirectoryError('MultiplexedPath only supports directories')
NotADirectoryError: MultiplexedPath only supports directories

======================================================================
ERROR: test_is_file (test.test_importlib.test_reader.MultiplexedPathTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/test_reader.py", line 51, in test_is_file
    self.assertEqual(MultiplexedPath(self.folder).is_file(), False)
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/importlib/readers.py", line 63, in __init__
    raise NotADirectoryError('MultiplexedPath only supports directories')
NotADirectoryError: MultiplexedPath only supports directories

======================================================================
ERROR: test_iterdir (test.test_importlib.test_reader.MultiplexedPathTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/test_reader.py", line 25, in test_iterdir
    contents = {path.name for path in MultiplexedPath(self.folder).iterdir()}
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/importlib/readers.py", line 63, in __init__
    raise NotADirectoryError('MultiplexedPath only supports directories')
NotADirectoryError: MultiplexedPath only supports directories

======================================================================
ERROR: test_iterdir_duplicate (test.test_importlib.test_reader.MultiplexedPathTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/test_reader.py", line 35, in test_iterdir_duplicate
    path.name for path in MultiplexedPath(self.folder, data01).iterdir()
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/importlib/readers.py", line 63, in __init__
    raise NotADirectoryError('MultiplexedPath only supports directories')
NotADirectoryError: MultiplexedPath only supports directories

======================================================================
ERROR: test_join_path (test.test_importlib.test_reader.MultiplexedPathTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/test_reader.py", line 66, in test_join_path
    path = MultiplexedPath(self.folder, data01)
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/importlib/readers.py", line 63, in __init__
    raise NotADirectoryError('MultiplexedPath only supports directories')
NotADirectoryError: MultiplexedPath only supports directories

======================================================================
ERROR: test_open_file (test.test_importlib.test_reader.MultiplexedPathTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/test_reader.py", line 54, in test_open_file
    path = MultiplexedPath(self.folder)
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/importlib/readers.py", line 63, in __init__
    raise NotADirectoryError('MultiplexedPath only supports directories')
NotADirectoryError: MultiplexedPath only supports directories

======================================================================
ERROR: test_repr (test.test_importlib.test_reader.MultiplexedPathTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/test_reader.py", line 82, in test_repr
    repr(MultiplexedPath(self.folder)),
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/importlib/readers.py", line 63, in __init__
    raise NotADirectoryError('MultiplexedPath only supports directories')
NotADirectoryError: MultiplexedPath only supports directories

======================================================================
ERROR: test_files (test.test_importlib.test_reader.NamespaceReaderTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/test_reader.py", line 115, in test_files
    namespacedata01 = import_module('namespacedata01')
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1049, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1026, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1003, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'namespacedata01'

======================================================================
ERROR: test_resource_path (test.test_importlib.test_reader.NamespaceReaderTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/test_reader.py", line 103, in test_resource_path
    namespacedata01 = import_module('namespacedata01')
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1049, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1026, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1003, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'namespacedata01'

======================================================================
ERROR: test_is_submodule_resource (test.test_importlib.test_resource.ResourceFromNamespaceTest01)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/test_resource.py", line 230, in test_is_submodule_resource
    resources.is_resource(import_module('namespacedata01'), 'binary.file')
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1049, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1026, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1003, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'namespacedata01'

======================================================================
ERROR: test_read_submodule_resource_by_name (test.test_importlib.test_resource.ResourceFromNamespaceTest01)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/test_resource.py", line 234, in test_read_submodule_resource_by_name
    self.assertTrue(resources.is_resource('namespacedata01', 'binary.file'))
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/importlib/resources.py", line 152, in is_resource
    package = _common.get_package(package)
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/importlib/_common.py", line 65, in get_package
    resolved = resolve(package)
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/importlib/_common.py", line 56, in resolve
    return cand if isinstance(cand, types.ModuleType) else importlib.import_module(cand)
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1049, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1026, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1003, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'namespacedata01'

======================================================================
ERROR: test_submodule_contents (test.test_importlib.test_resource.ResourceFromNamespaceTest01)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/test_resource.py", line 237, in test_submodule_contents
    contents = set(resources.contents(import_module('namespacedata01')))
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1049, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1026, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1003, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'namespacedata01'

======================================================================
ERROR: test_submodule_contents_by_name (test.test_importlib.test_resource.ResourceFromNamespaceTest01)
----------------------------------------------------------------------
test test_importlib failed
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/test/test_importlib/test_resource.py", line 245, in test_submodule_contents_by_name
    contents = set(resources.contents('namespacedata01'))
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/importlib/resources.py", line 170, in contents
    package = _common.get_package(package)
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/importlib/_common.py", line 65, in get_package
    resolved = resolve(package)
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/importlib/_common.py", line 56, in resolve
    return cand if isinstance(cand, types.ModuleType) else importlib.import_module(cand)
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang-installed/build/target/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1049, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1026, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1003, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'namespacedata01'
msg389161 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-03-20 14:58
It seems like tests were added by:

commit 67148254146948041a77d8a2989f41b88cdb2f99
Author: Jason R. Coombs <jaraco@jaraco.com>
Date:   Thu Mar 4 13:43:00 2021 -0500

    bpo-42129: Add support for resources in namespaces (GH-24670)
    
    * Unify behavior in ResourceReaderDefaultsTests and align with the behavior found in importlib_resources.
    * Equip NamespaceLoader with a NamespaceReader.
    * Apply changes from importlib_resources 5.0.4
msg389175 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2021-03-20 19:44
Interestingly, the pull request never alerted to any buildbot failures.

Any idea how I can reproduce the issue locally? Is there a docker image that would likely replicate the environment in which the tests are failing?
msg389182 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2021-03-20 21:47
Oh, "installed python". So maybe Python requires one register files in more than one place to add them to the installation.
msg389194 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2021-03-20 23:02
I've submitted a PR and triggered build by buildbots, but I don't see that the indicated builder is building the PR. Shall I just submit and see what happens? Any other ideas how to verify the installed builder buildbots?
msg389251 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2021-03-21 17:24
You can find your submitted change here by looking here:
https://buildbot.python.org/all/#/changes

For some reason, though, it seems that no build was triggered:
https://buildbot.python.org/all/#/changes/3344

In any case, the fix is a no-brainer.
msg389252 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2021-03-21 17:26
New changeset 9a50ef43e42ee32450a81ce13ed5a0729d3b84e8 by Jason R. Coombs in branch 'master':
bpo-43569: Add test/test_importlib/namespacedata01 to TESTSUBDIRS (GH-24952)
https://github.com/python/cpython/commit/9a50ef43e42ee32450a81ce13ed5a0729d3b84e8
msg389255 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2021-03-21 18:24
Unfortunately, it seems the patch didn't have the intended effect. The [build is still failing](https://buildbot.python.org/all/#/builders/14/builds/810). So I'm left without a way to test without committing code to the main branch.
msg389256 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2021-03-21 18:40
I don't think that build includes your change.
Here are the builds that have been triggered (the list seems incomplete for now):
https://buildbot.python.org/all/#/changes/3355
msg389257 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2021-03-21 18:43
Okay, I think you may be right. I saw your name on the build and assumed that meant the merge triggered that build. I'll trigger a build now.
msg389258 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2021-03-21 18:46
Assuming Antoine is correct (a likely story), I'm closing and will only re-open if a subsequent failure is confirmed to have run and failed after the submission. Sorry for the noise.
msg389287 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-03-22 09:01
I confirm that aarch64 Fedora Stable Clang Installed 3.x is back to green, thanks for the fix.
History
Date User Action Args
2021-03-22 09:01:01vstinnersetmessages: + msg389287
2021-03-21 18:46:06jaracosetstatus: open -> closed
resolution: fixed
messages: + msg389258
2021-03-21 18:43:02jaracosetmessages: + msg389257
2021-03-21 18:40:39pitrousetmessages: + msg389256
2021-03-21 18:24:50jaracosetstatus: closed -> open
resolution: fixed -> (no value)
messages: + msg389255
2021-03-21 17:27:19pitrousetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-03-21 17:26:51pitrousetmessages: + msg389252
2021-03-21 17:24:55pitrousetnosy: + pitrou
messages: + msg389251
2021-03-20 23:02:12jaracosetmessages: + msg389194
2021-03-20 21:59:06jaracosetkeywords: + patch
stage: patch review
pull_requests: + pull_request23710
2021-03-20 21:47:51jaracosetmessages: + msg389182
2021-03-20 19:44:18jaracosetmessages: + msg389175
2021-03-20 19:31:56jaracosetassignee: jaraco

nosy: + jaraco
2021-03-20 14:58:26vstinnersetmessages: + msg389161
2021-03-20 14:58:06vstinnercreate