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 on copy.copy() of dict value accessed with static key set elsewhere #4891

Closed
jacobtylerwalls opened this issue Aug 21, 2021 · 1 comment · Fixed by #4892
Closed

Crash on copy.copy() of dict value accessed with static key set elsewhere #4891

jacobtylerwalls opened this issue Aug 21, 2021 · 1 comment · Fixed by #4892
Labels
Bug 🪲 Crash 💥 A bug that makes pylint crash
Milestone

Comments

@jacobtylerwalls
Copy link
Member

Bug description

# pylint: disable=missing-module-docstring
# pylint: disable=too-few-public-methods
import copy

class MyData:
    '''
    class docstring
    '''
    def __init__(self):
        self.data = {}

    def process(self):
        '''
        another method is responsible for putting "static_key"
        '''
        copy.copy(self.data['static_key'])



pylint crashed with a ``InferenceError`` and with the following stacktrace:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/inference.py", line 401, in infer_subscript
assigned = value.getitem(index_value, context)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/nodes/node_classes.py", line 2252, in getitem
raise AstroidIndexError(index)
astroid.exceptions.AstroidIndexError:

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pylint/lint/pylinter.py", line 1024, in _check_files
self._check_file(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pylint/lint/pylinter.py", line 1063, in _check_file
check_astroid_module(ast_node)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pylint/lint/pylinter.py", line 1200, in check_astroid_module
retval = self._check_astroid_module(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pylint/lint/pylinter.py", line 1245, in _check_astroid_module
walker.walk(ast_node)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pylint/utils/ast_walker.py", line 78, in walk
self.walk(child)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pylint/utils/ast_walker.py", line 78, in walk
self.walk(child)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pylint/utils/ast_walker.py", line 78, in walk
self.walk(child)
[Previous line repeated 1 more time]
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pylint/utils/ast_walker.py", line 75, in walk
callback(astroid)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pylint/checkers/stdlib.py", line 537, in visit_call
self._check_shallow_copy_environ(node)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pylint/checkers/stdlib.py", line 488, in _check_shallow_copy_environ
for inferred in arg.inferred():
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/nodes/node_ng.py", line 465, in inferred
return list(self.infer())
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/nodes/node_ng.py", line 99, in infer
yield from self._infer(context, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/decorators.py", line 136, in raise_if_nothing_inferred
yield next(generator)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/decorators.py", line 100, in wrapped
res = next(generator)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/inference.py", line 408, in infer_subscript
raise InferenceError(node=self, context=context) from exc
astroid.exceptions.InferenceError: Inference failed for <Subscript l.16 at 0x7fd870e47400>.

Configuration

No response

Command used

python -m pylint error_report

Pylint output

Exception on node <Call l.16 at 0x7fd870e47520> in file '/Users/.../fifth'
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/inference.py", line 401, in infer_subscript
    assigned = value.getitem(index_value, context)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/nodes/node_classes.py", line 2252, in getitem
    raise AstroidIndexError(index)
astroid.exceptions.AstroidIndexError: <unprintable AstroidIndexError object>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pylint/utils/ast_walker.py", line 75, in walk
    callback(astroid)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pylint/checkers/stdlib.py", line 537, in visit_call
    self._check_shallow_copy_environ(node)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pylint/checkers/stdlib.py", line 488, in _check_shallow_copy_environ
    for inferred in arg.inferred():
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/nodes/node_ng.py", line 465, in inferred
    return list(self.infer())
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/nodes/node_ng.py", line 99, in infer
    yield from self._infer(context, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/decorators.py", line 136, in raise_if_nothing_inferred
    yield next(generator)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/decorators.py", line 100, in wrapped
    res = next(generator)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/inference.py", line 408, in infer_subscript
    raise InferenceError(node=self, context=context) from exc
astroid.exceptions.InferenceError: Inference failed for <Subscript l.16 at 0x7fd870e47400>.
************* Module fifth
fifth:1:0: F0002: fifth: Fatal error while checking 'fifth'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in '/Users/.../Library/Caches/pylint/pylint-crash-2021-08-21-11.txt'. (astroid-error)

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

Expected behavior

no messages

Pylint version

pylint 2.10.1
astroid 2.7.2
Python 3.9.6 (v3.9.6:db3ff76da1, Jun 28 2021, 11:49:53) 
[Clang 6.0 (clang-600.0.57)]

OS / Environment

macOS 11.3.1 as well as Ubuntu 20.04.2 LTS on GitHub Actions

Additional dependencies

n/a

@jacobtylerwalls jacobtylerwalls added Bug 🪲 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Aug 21, 2021
@Pierre-Sassoulas Pierre-Sassoulas added Crash 💥 A bug that makes pylint crash and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Aug 21, 2021
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.10.2 milestone Aug 21, 2021
Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Aug 21, 2021
@Pierre-Sassoulas
Copy link
Member

Thank you for creating the issue, it's fixed in 2.10.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Crash 💥 A bug that makes pylint crash
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants