You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
************* Module test
test.py:1:0: C0114: Missing module docstring (missing-module-docstring)
cffi_example._person.lib
Exception on node <ImportFrom l.1 at 0x7f637397f700> in file '/tmp/test.py'
Traceback (most recent call last):
File "/home/dalcinl/.local/lib/python3.10/site-packages/astroid/modutils.py", line 590, in _spec_from_modpath
found_spec = spec.find_spec(modpath, [context])
File "/home/dalcinl/.local/lib/python3.10/site-packages/astroid/interpreter/_import/spec.py", line 393, in find_spec
finder, spec = _find_spec_with_path(
File "/home/dalcinl/.local/lib/python3.10/site-packages/astroid/interpreter/_import/spec.py", line 362, in _find_spec_with_path
raise ImportError(f"No module named {'.'.join(module_parts)}")
ImportError: No module named cffi_example._person.lib
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/dalcinl/.local/lib/python3.10/site-packages/pylint/utils/ast_walker.py", line 90, in walk
callback(astroid)
File "/home/dalcinl/.local/lib/python3.10/site-packages/pylint/checkers/imports.py", line 523, in visit_importfrom
self._add_imported_module(node, f"{imported_module.name}.{name}")
File "/home/dalcinl/.local/lib/python3.10/site-packages/pylint/checkers/imports.py", line 833, in _add_imported_module
importedmodname = astroid.modutils.get_module_part(
File "/home/dalcinl/.local/lib/python3.10/site-packages/astroid/modutils.py", line 438, in get_module_part
file_from_modpath(
File "/home/dalcinl/.local/lib/python3.10/site-packages/astroid/modutils.py", line 334, in file_from_modpath
return file_info_from_modpath(modpath, path, context_file).location
File "/home/dalcinl/.local/lib/python3.10/site-packages/astroid/modutils.py", line 384, in file_info_from_modpath
return _spec_from_modpath(modpath, path, context)
File "/home/dalcinl/.local/lib/python3.10/site-packages/astroid/modutils.py", line 593, in _spec_from_modpath
found_spec = spec.find_spec(modpath, path)
File "/home/dalcinl/.local/lib/python3.10/site-packages/astroid/interpreter/_import/spec.py", line 393, in find_spec
finder, spec = _find_spec_with_path(
File "/home/dalcinl/.local/lib/python3.10/site-packages/astroid/interpreter/_import/spec.py", line 355, in _find_spec_with_path
spec = finder_instance.find_module(
File "/home/dalcinl/.local/lib/python3.10/site-packages/astroid/interpreter/_import/spec.py", line 205, in find_module
submodule_path = sys.modules[modname].__path__
AttributeError: cffi library 'cffi_example._person' has no function, constant or global variable named '__path__'
test.py:1:0: F0002: test.py: Fatal error while checking 'test.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in '/home/dalcinl/.cache/pylint/pylint-crash-2022-09-09-21-23-07.txt'. (astroid-error)
------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)
CFFI inject objects in sys.modules that are not real module objects:
In [1]: import sys
In [2]: import cffi_example._person
In [3]: lib = sys.modules['cffi_example._person.lib']
In [4]: print(type(lib), type(lib).__base__)
<class '_cffi_backend.Lib'> <class 'object'>
In [5]: lib
Out[5]: <Lib object for 'cffi_example._person'>
As astroid is asking for the missing __path__ attribute, things go bad.
However, looking at astroid sources, I don't think that the root of the issue, but rather a confusion with detection of namespace packages.
The text was updated successfully, but these errors were encountered:
Steps to reproduce
Current behavior
Expected behavior
No traceback!
python -c "from astroid import __pkginfo__; print(__pkginfo__.version)"
outputAdditional information
CFFI inject objects in
sys.modules
that are not real module objects:As
astroid
is asking for the missing__path__
attribute, things go bad.However, looking at
astroid
sources, I don't think that the root of the issue, but rather a confusion with detection of namespace packages.The text was updated successfully, but these errors were encountered: