Closed kornoa closed 2 months ago
Thanks for this @kornoa! The reproducer can be simplified to:
class A:
def say_hello(self) -> __module__:
...
At first glance, defframe.locals[node.name][0]
is an astroid node representing the name of the module in which PyTemplate
is defined and which doesn't have a lineno.
I got another NoneType in an Astroid callback, but with this code:
from dataclasses import dataclass
from enum import Enum
@dataclass
class Status(Enum):
OFF = 0
Exception on node <AssignName.OFF l.7 at 0x7f11f4f0c1d0> in file '/home/an/git/zivid-sdk/relay_control.py'
Traceback (most recent call last):
File "venv/lib64/python3.11/site-packages/pylint/utils/ast_walker.py", line 91, in walk
callback(astroid)
File "venv/lib64/python3.11/site-packages/pylint/checkers/base/name_checker/checker.py", line 488, in visit_assignname
if utils.is_enum_member(node) or utils.is_assign_name_annotated_with(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "venv/lib64/python3.11/site-packages/pylint/checkers/utils.py", line 2284, in is_enum_member
enum_member_objects = frame.locals.get("__members__")[0].items
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
TypeError: 'NoneType' object is not subscriptable
I can reproduce it in a minimal venv from this requirements.txt:
#
# Generated by:
# echo pylint > requiremetns.in && pip-compile --strip-extras requirements.in
#
astroid==3.0.0
dill==0.3.7
isort==5.12.0
mccabe==0.7.0
platformdirs==3.11.0
pylint==3.0.0
tomlkit==0.12.1
From this, I can also reproduce the simplified reproducer above.
Thanks for checking old issues. That seems to be https://github.com/pylint-dev/pylint/issues/9100 which is resolved on master
!
Bug description
pylint crashed with a
AstroidError
Configuration
Command used
Pylint output
Expected behavior
No exception
Pylint version
OS / Environment
cat /etc/os-release PRETTY_NAME="Ubuntu 22.04.2 LTS" NAME="Ubuntu" VERSION_ID="22.04" VERSION="22.04.2 LTS (Jammy Jellyfish)" VERSION_CODENAME=jammy ID=ubuntu ID_LIKE=debian HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" UBUNTU_CODENAME=jammy
Additional dependencies
cat /home/knoack/.cache/pylint/pylint-crash-2023-07-20-13-04-04.txt First, please verify that the bug is not already filled: https://github.com/PyCQA/pylint/issues/
Then create a new crash issue: https://github.com/PyCQA/pylint/issues/new?assignees=&labels=crash%2Cneeds+triage&template=BUG-REPORT.yml
Issue title: Crash ```` (if possible, be more specific about what made pylint crash) Content: When parsing the following file:
pylint crashed with a
AstroidError
and with the following stacktrace: