Closed greyblue9 closed 3 years ago
I'll have to review this later today, ci isn't set up atm
@greyblue9 currently python 3.11 is not available on github actions, do you have any suggestion for a unittest that could catch this
also please rebase to the new pipelines
@greyblue9 currently python 3.11 is not available on github actions, do you have any suggestion for a unittest that could catch this
also please rebase to the new pipelines
I'm happy to do this, is there a specific bramch I should rebase to? Could you be more specific?
Perhaps more interesting, I just tested 3.11 with the 'mozernize' branch, and the commit there fixes the issue as well. (#19 'fix #13: pass over spec and test aliases/specs')
I could write tests that would catch the issue even if 3.11 isn't the version on the runner. I build and ran 3.10b2 this morning (latest version that 'setup-python' supports) and didn't encounter the issue, so it definitely seems like from 3.11 importlib internals are relying on __spec__
rebase onto the current main which has one spec attribute already added and
rebase onto the current main which has one spec attribute already added and
That fix is all that's necessary; you can ignore this PR. Sorry I originally didn't have things symlinked properly to do a true test (and avoid py's vendored version)
Here's some more info I tracked down (left the same research under an isdue in pytest-dev/py repo):
The cause of this error I tracked down to this change (commit 0a8ae8a50a0fea3d39ec49b220a5c7a5b70e36f8 in cpython): 'bpo-44717: improve AttributeError on circular imports of submodules (GH-27338)' https://bugs.python.org/issue44717
it introduces the parent = parent_module.__spec__
line in importlib.
AttributeError: __spec__
(which is thrown from importlib, while KeyError
in apipkg is being handled)
The latest master and modernization branches fix the issue in pytest (and apipkg standalone) for me.
From the stack in importlib:
File /data/media/0/src/python3/src/Lib/importlib/_bootstrap.py, line 1044, in _find_and_load
return _find_and_load_unlocked(name, import_):
File /data/media/0/src/python3/src/Lib/importlib/_bootstrap.py, line 994, in _find_and_load_unlocked
_call_with_frames_removed(import_, parent):
File /data/media/0/src/python3/src/Lib/importlib/_bootstrap.py, line 241, in _call_with_frames_removed
return f(*args, **kwds):
File /data/media/0/src/python3/src/Lib/importlib/_bootstrap.py, line 1044, in _find_and_load
return _find_and_load_unlocked(name, import_):
File /data/media/0/src/python3/src/Lib/importlib/_bootstrap.py, line 1004, in _find_and_load_unlocked
parent_spec = parent_module.__spec__:
On Python 3.11, I receive an error when importing either pytest or (directly) py._path or py.path.
The cause seems to be the spec is not set on ApiModule, which is necessary for successful import of subpackages on Python 3.11.
This commit fixes the issue for me.