Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_do_not_import_files_from_local_directory fails with trying to import "completely_unknown" #3636

Closed
Labels
Milestone

Comments

@bnavigator
Copy link
Contributor

(Same environment as in #3635)

Trying to update the openSUSE package for pylint:

[    5s] ============================= test session starts ==============================
[    5s] platform linux -- Python 3.8.2, pytest-5.3.5, py-1.8.1, pluggy-0.13.1 -- /usr/bin/python3
[    5s] cachedir: .pytest_cache
[    5s] benchmark: 3.2.3 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
[    5s] rootdir: /home/abuild/rpmbuild/BUILD/pylint-2.5.2, inifile: pytest.ini
[    5s] plugins: forked-1.1.3, xdist-1.32.0, benchmark-3.2.3
[    7s] collecting ... collected 1404 items / 194 deselected / 1210 selected
...
[  151s] ___________ TestRunTC.test_do_not_import_files_from_local_directory ____________
[  151s] 
...
[  151s]             if check and retcode:
[  151s] >               raise CalledProcessError(retcode, process.args,
[  151s]                                          output=stdout, stderr=stderr)
[  151s] E               subprocess.CalledProcessError: Command '['/usr/bin/python3', '-m', 'pylint', 'astroid.py', '--disable=import-error,unused-import']' returned non-zero exit status 1.
[  151s] 
[  151s] /usr/lib64/python3.8/subprocess.py:512: CalledProcessError
[  151s] ----------------------------- Captured stderr call -----------------------------
[  151s] Traceback (most recent call last):
[  151s]   File "/usr/lib64/python3.8/runpy.py", line 193, in _run_module_as_main
[  151s]     return _run_code(code, main_globals, None,
[  151s]   File "/usr/lib64/python3.8/runpy.py", line 86, in _run_code
[  151s]     exec(code, run_globals)
[  151s]   File "/home/abuild/rpmbuild/BUILDROOT/python-pylint-2.5.2-0.x86_64/usr/lib/python3.8/site-packages/pylint/__main__.py", line 18, in <module>
[  151s]     pylint.run_pylint()
[  151s]   File "/home/abuild/rpmbuild/BUILDROOT/python-pylint-2.5.2-0.x86_64/usr/lib/python3.8/site-packages/pylint/__init__.py", line 19, in run_pylint
[  151s]     from pylint.lint import Run as PylintRun
[  151s]   File "/home/abuild/rpmbuild/BUILDROOT/python-pylint-2.5.2-0.x86_64/usr/lib/python3.8/site-packages/pylint/lint/__init__.py", line 75, in <module>
[  151s]     from pylint.lint.check_parallel import check_parallel
[  151s]   File "/home/abuild/rpmbuild/BUILDROOT/python-pylint-2.5.2-0.x86_64/usr/lib/python3.8/site-packages/pylint/lint/check_parallel.py", line 7, in <module>
[  151s]     from pylint import reporters
[  151s]   File "/home/abuild/rpmbuild/BUILDROOT/python-pylint-2.5.2-0.x86_64/usr/lib/python3.8/site-packages/pylint/reporters/__init__.py", line 24, in <module>
[  151s]     from pylint import utils
[  151s]   File "/home/abuild/rpmbuild/BUILDROOT/python-pylint-2.5.2-0.x86_64/usr/lib/python3.8/site-packages/pylint/utils/__init__.py", line 46, in <module>
[  151s]     from pylint.utils.ast_walker import ASTWalker
[  151s]   File "/home/abuild/rpmbuild/BUILDROOT/python-pylint-2.5.2-0.x86_64/usr/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 6, in <module>
[  151s]     from astroid import nodes
[  151s]   File "/tmp/pytest-of-abuild/pytest-57/test_do_not_import_files_from_0/astroid.py", line 2, in <module>
[  151s]     import completely_unknown
[  151s] ModuleNotFoundError: No module named 'completely_unknown'

What could cause the undesired import? If I chroot into the build environment and call
python3 -m pylint astroid.py, I get the same ModuleNotFoundError.

But if I install the package onto a live openSUSE Tumbleweed system and execute the same call, the import does not happen.

Package versions:

python3-astroid-2.4.1
python3-isort-4.3.21
python3-mccabe-0.6.1
python3-toml-0.10.0

For the full environment, see the build log as linked above.

@bnavigator
Copy link
Contributor Author

Ha! Found it.

PYTHONPATH is set by the %pytest rpm macro to :/home/abuild/rpmbuild/BUILDROOT/python-pylint-2.5.2-0.x86_64/usr/lib/python3.8/site-packages. The leading ":" means the effective sys.path is ['', cwd, ...] and then the code https://github.com/PyCQA/pylint/blob/1fc490c0a1d0df5d4d6a64da0ccf2dd711b9bf67/pylint/__main__.py#L15-L16 does not strip the second entry.

@PCManticore PCManticore added this to the 2.5.3 release milestone May 28, 2020
@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 2.7.0, 2.7.x Feb 20, 2021
sbraz added a commit to sbraz/pylint that referenced this issue Feb 28, 2021
51c646b only stripped the first bad
sys.path entry, causing problems when PYTHONPATH starts or ends with a
colon.
sbraz added a commit to sbraz/pylint that referenced this issue Feb 28, 2021
51c646b only stripped the first bad
sys.path entry, causing problems when PYTHONPATH starts or ends with a
colon.
sbraz added a commit to sbraz/pylint that referenced this issue Feb 28, 2021
51c646b only stripped the first bad
sys.path entry, causing problems when PYTHONPATH starts or ends with a
colon.

Closes: pylint-dev#3636
sbraz added a commit to sbraz/pylint that referenced this issue Feb 28, 2021
51c646b only stripped the first bad
sys.path entry, causing problems when PYTHONPATH starts or ends with a
colon.

Closes: pylint-dev#3636
sbraz added a commit to sbraz/pylint that referenced this issue Feb 28, 2021
51c646b only stripped the first bad
sys.path entry, causing problems when PYTHONPATH starts or ends with a
colon.

Closes: pylint-dev#3636
sbraz added a commit to sbraz/pylint that referenced this issue Feb 28, 2021
51c646b only stripped the first bad
sys.path entry, causing problems when PYTHONPATH starts or ends with a
colon.

Closes: pylint-dev#3636
Pierre-Sassoulas pushed a commit that referenced this issue Feb 28, 2021
…4153)

51c646b only stripped the first bad
sys.path entry, causing problems when PYTHONPATH starts or ends with a
colon.

Closes: #3636
This was referenced Mar 1, 2021
@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 2.8.x, 2.8.0 Apr 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment