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

Crash parsing file where a dictionaries value is being assigned to None #7461

Closed
jaserieger opened this issue Sep 14, 2022 · 1 comment · Fixed by #7472
Closed

Crash parsing file where a dictionaries value is being assigned to None #7461

jaserieger opened this issue Sep 14, 2022 · 1 comment · Fixed by #7472
Assignees
Labels
Crash 💥 A bug that makes pylint crash Needs PR This issue is accepted, sufficiently specified and now needs an implementation Regression
Milestone

Comments

@jaserieger
Copy link

jaserieger commented Sep 14, 2022

Bug description

Pylint fails to parse this file and crashes. The error is the temp_post_data[key] = None as removing that line works, additionally change from for key in self.request_data: to for key, _ in self.request_data.items(): also works

"""
Simple test class to show astroid error
"""
import unittest


class AstroidErrorTest(unittest.TestCase):
    """simple test class to show astroid error"""
    @property
    def request_data(self):
        """Data that would be POSTed"""
        return {"ref":          'ref',
                "project_id":   12,
                "checkout_sha": 'hash'}

    def test_key_is_none(self):
        """Failure case where the data being POSTed has an expected key being None

          Expected Behaviour: POST with no data. Should return 400 json response."""
        for key in self.request_data:
            temp_post_data= self.request_data.copy()
            temp_post_data[key] = None
            self.assertIsNone(temp_post_data[key])
            # Do the post and validation


if __name__ == '__main__':
    unittest.main()

pylint-crash-2022-09-14-14-14-11.zip

Configuration

No response

Command used

pylint testfile.py

Pylint output

Exception on node <For l.20 at 0x242c2610070> in file 'C:\Work\cdt\testfile.py'
Traceback (most recent call last):
  File "C:\Work\cdt\venv\lib\site-packages\pylint\utils\ast_walker.py", line 90, in walk
    callback(astroid)
  File "C:\Work\cdt\venv\lib\site-packages\pylint\checkers\modified_iterating_checker.py", line 60, in visit_for
    self._modified_iterating_check_on_node_and_children(body_node, iter_obj)
  File "C:\Work\cdt\venv\lib\site-packages\pylint\checkers\modified_iterating_checker.py", line 66, in _modified_iterating_check_on_node_and_children
    self._modified_iterating_check(body_node, iter_obj)
  File "C:\Work\cdt\venv\lib\site-packages\pylint\checkers\modified_iterating_checker.py", line 88, in _modified_iterating_check
    elif self._modified_iterating_dict_cond(node, iter_obj):
  File "C:\Work\cdt\venv\lib\site-packages\pylint\checkers\modified_iterating_checker.py", line 162, in _modified_iterating_dict_cond
    return node.targets[0].value.name == iter_obj.name
AttributeError: 'Attribute' object has no attribute 'name'
************* Module testfile
testfile.py:1:0: F0002: testfile.py: Fatal error while checking 'testfile.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\jase.rieger\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-09-14-14-14-11.txt'. (astroid-error)

-----------------------------------
Your code has been rated at 0.00/10

Expected behavior

Pylint to pass the file.

Works with:
pylint 2.15.0
astroid 2.12.9
Python 3.9.10 (tags/v3.9.10:f2f3f53, Jan 17 2022, 15:14:21) [MSC v.1929 64 bit (AMD64)]

Pylint version

pylint 2.15.2
astroid 2.12.9
Python 3.9.10 (tags/v3.9.10:f2f3f53, Jan 17 2022, 15:14:21) [MSC v.1929 64 bit (AMD64)]

OS / Environment

No response

Additional dependencies

No response

@jaserieger jaserieger added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Sep 14, 2022
@Pierre-Sassoulas Pierre-Sassoulas added Crash 💥 A bug that makes pylint crash Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Sep 14, 2022
@jacobtylerwalls
Copy link
Member

Thanks for the report, regression in bcd4ca3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Crash 💥 A bug that makes pylint crash Needs PR This issue is accepted, sufficiently specified and now needs an implementation Regression
Projects
None yet
3 participants