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

astroid 2.4 / pylint 2.5: astroid error when using PyQt/Qt's QApplication #772

Closed
The-Compiler opened this issue Apr 27, 2020 · 2 comments
Closed
Assignees

Comments

@The-Compiler
Copy link
Contributor

The-Compiler commented Apr 27, 2020

Steps to reproduce

  1. pip install -U pip (especially with a virtualenv, so that a manylinux2014 wheel is found for PyQt rather than pip trying to build from sources)
  2. pip install pylint PyQt5
  3. Run pylint --extension-pkg-whitelist=PyQt5 keytester.py over this file:
from PyQt5.QtWidgets import QApplication
app = QApplication([])

(a pretty standard PyQt set-up)

Current behavior

Astroid fails with:

Traceback (most recent call last):
  File ".venv/bin/pylint", line 10, in <module>
    sys.exit(run_pylint())
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/pylint/__init__.py", line 22, in run_pylint
    PylintRun(sys.argv[1:])
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/pylint/lint/run.py", line 338, in __init__
    linter.check(args)
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 870, in check
    self._check_files(
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 904, in _check_files
    self._check_file(get_ast, check_astroid_module, name, filepath, modname)
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 930, in _check_file
    check_astroid_module(ast_node)
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1062, in check_astroid_module
    retval = self._check_astroid_module(
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1107, in _check_astroid_module
    walker.walk(ast_node)
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 75, in walk
    self.walk(child)
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 72, in walk
    callback(astroid)
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/pylint/checkers/variables.py", line 1197, in visit_importfrom
    module = self._check_module_attrs(node, module, name_parts[1:])
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/pylint/checkers/variables.py", line 1868, in _check_module_attrs
    module = next(module.getattr(name)[0].infer())
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/astroid/scoped_nodes.py", line 547, in getattr
    result = [self.import_module(name, relative_only=True)]
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/astroid/scoped_nodes.py", line 642, in import_module
    return MANAGER.ast_from_module_name(absmodname)
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/astroid/manager.py", line 168, in ast_from_module_name
    return self.ast_from_module(module, modname)
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/astroid/manager.py", line 262, in ast_from_module
    return AstroidBuilder(self).module_build(module, modname)
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/astroid/builder.py", line 95, in module_build
    node = self.inspect_build(module, modname=modname, path=path)
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/astroid/raw_building.py", line 308, in inspect_build
    self.object_build(node, module)
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/astroid/raw_building.py", line 360, in object_build
    elif hasattr(member, "__all__"):
RuntimeError: wrapped C/C++ object of type QApplication has been deleted

That exception is coming from PyQt and usually happens when Qt already deleted an object in C++, but something still holds a Python reference to it. Not sure how that can even happen with a QApplication object, though.

Expected behavior

pylint works successfully, other than the missing-module-docstring and invalid-name errors - this was the case with pylint 2.4.4 and astroid 2.3.3.

python -c "from astroid import __pkginfo__; print(__pkginfo__.version)" output

2.4.0 (and pylint 2.5.0)

The-Compiler added a commit to qutebrowser/qutebrowser that referenced this issue Apr 27, 2020
Blacklists pylint/astroid upgrades for now, because of:
pylint-dev/astroid#772
PCManticore added a commit that referenced this issue Apr 28, 2020
…`` attribute

PyQT does something special with their objects and retrieving some of
them (such as `__all__`) at runtime results in a RuntimeError.
This patch simply swallows all the exceptions that accessing `__all__`
might raise.

Close #772
@PCManticore PCManticore self-assigned this Apr 28, 2020
PCManticore added a commit that referenced this issue Apr 28, 2020
…`` attribute

PyQT does something special with their objects and retrieving some of
them (such as `__all__`) at runtime results in a RuntimeError.
This patch simply swallows all the exceptions that accessing `__all__`
might raise.

Close #772
PCManticore added a commit that referenced this issue Apr 28, 2020
…`` attribute

PyQT does something special with their objects and retrieving some of
them (such as `__all__`) at runtime results in a RuntimeError.
This patch simply swallows all the exceptions that accessing `__all__`
might raise.

Close #772
@PCManticore
Copy link
Contributor

Addressed by #776, will release it in the following days along with other urgent patches.

PCManticore added a commit that referenced this issue Apr 28, 2020
…`` attribute

PyQT does something special with their objects and retrieving some of
them (such as `__all__`) at runtime results in a RuntimeError.
This patch simply swallows all the exceptions that accessing `__all__`
might raise.

Close #772
@The-Compiler
Copy link
Contributor Author

Awesome, thank you! 👍

The-Compiler added a commit to qutebrowser/qutebrowser that referenced this issue Dec 2, 2021
We pinned pylint to < 2.5 due to this issue:
pylint-dev/astroid#772

...but then for some reaosn never unpinned it after the issue was fixed.
mkonig pushed a commit to mkonig/qutebrowser that referenced this issue Dec 7, 2021
We pinned pylint to < 2.5 due to this issue:
pylint-dev/astroid#772

...but then for some reaosn never unpinned it after the issue was fixed.
twigleingrid pushed a commit to twigleingrid/qutebrowser that referenced this issue May 13, 2022
We pinned pylint to < 2.5 due to this issue:
pylint-dev/astroid#772

...but then for some reaosn never unpinned it after the issue was fixed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants