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 when attempting to access a builtin's __code__ #6539

Closed
jacobtylerwalls opened this issue May 7, 2022 · 0 comments · Fixed by #6554
Closed

Crash when attempting to access a builtin's __code__ #6539

jacobtylerwalls opened this issue May 7, 2022 · 0 comments · Fixed by #6554
Labels
Astroid Related to astroid Crash 💥 A bug that makes pylint crash Needs astroid update Needs an astroid update (probably a release too) before being mergable
Milestone

Comments

@jacobtylerwalls
Copy link
Member

jacobtylerwalls commented May 7, 2022

Bug description

Simplified from an example in cloudpickle, where it was guarded by if PYPY:

Updated to remove the use of a pylint extension.

a = type(float.__new__.__code__)

Configuration

n/a

Command used

pylint a.py

Pylint output

Exception on node <AssignName.a l.1 at 0x10c91c580> in file '/Users/.../pylint/a.py'
Traceback (most recent call last):
  File "/Users/.../astroid/astroid/inference_tip.py", line 37, in _inference_tip_cached
    result = _cache[func, node]
KeyError: (<function register_builtin_transform.<locals>._transform_wrapper at 0x10c339630>, <Call l.1 at 0x10c91c640>)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/.../pylint/pylint/utils/ast_walker.py", line 89, in walk
    callback(astroid)
  File "/Users/.../pylint/pylint/checkers/base/name_checker/checker.py", line 394, in visit_assignname
    inferred_assign_type = utils.safe_infer(assign_type.value)
  File "/Users/.../pylint/pylint/checkers/utils.py", line 1247, in safe_infer
    value = next(infer_gen)
  File "/Users/.../astroid/astroid/nodes/node_ng.py", line 156, in infer
    results = list(self._explicit_inference(self, context, **kwargs))
  File "/Users/.../astroid/astroid/inference_tip.py", line 44, in _inference_tip_cached
    result = _cache[func, node] = list(func(*args, **kwargs))
  File "/Users/.../astroid/astroid/brain/brain_builtin_inference.py", line 172, in _transform_wrapper
    result = transform(node, context=context)
  File "/Users/.../astroid/astroid/brain/brain_builtin_inference.py", line 599, in infer_type
    return helpers.object_type(node.args[0], context)
  File "/Users/.../astroid/astroid/helpers.py", line 73, in object_type
    types = set(_object_type(node, context))
  File "/Users/.../astroid/astroid/helpers.py", line 59, in _object_type
    yield inferred._proxied
AttributeError: 'Unknown' object has no attribute '_proxied'

Expected behavior

no crash

Pylint version

Not caused recently.

pylint 2.14.0-dev0
astroid 2.12.0-dev0
Python 3.10.1 (v3.10.1:2cd268a3a9, Dec  6 2021, 14:28:59) [Clang 13.0.0 (clang-1300.0.29.3)]

OS / Environment

Use s CPython interpreter instead of PyPy so that __code__ is missing:

AttributeError: 'builtin_function_or_method' object has no attribute '__code__'. Did you mean: '__call__'?

Additional dependencies

No response

@jacobtylerwalls jacobtylerwalls added Astroid Related to astroid Crash 💥 A bug that makes pylint crash labels May 7, 2022
@jacobtylerwalls jacobtylerwalls changed the title Crash in redefined-variable-type when attempting to access a builtin's __code__ Crash when attempting to access a builtin's __code__ May 7, 2022
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.13.9 milestone May 7, 2022
@Pierre-Sassoulas Pierre-Sassoulas added the Needs astroid update Needs an astroid update (probably a release too) before being mergable label May 7, 2022
jacobtylerwalls added a commit to jacobtylerwalls/pylint that referenced this issue May 9, 2022
Pierre-Sassoulas pushed a commit that referenced this issue May 9, 2022
Pierre-Sassoulas pushed a commit that referenced this issue May 9, 2022
Pierre-Sassoulas pushed a commit that referenced this issue May 9, 2022
Pierre-Sassoulas pushed a commit that referenced this issue May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Astroid Related to astroid Crash 💥 A bug that makes pylint crash Needs astroid update Needs an astroid update (probably a release too) before being mergable
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants