pylint-dev / pylint-dev/astroid

Name lookup can lead to maximum recursion errors in certain situations

Open
#264 1 comment 0 reactions 0 assignees View on GitHub
Bug 🪳
Dominant language
Python
Stars
582
Forks
357
Avg merge
1d 1h
Merged PRs (30d)
23

Description

Originally reported by: **Claudiu Popa (BitBucket: [PCManticore](http://bitbucket.org/PCManticore), GitHub: @PCManticore)**

---

Given the following code, astroid will crash with a RuntimeError. The problem occurs because k is not inferred as the argument, but as the iterating element from the comprehension, which makes dict(**k) to be reevaluated at each inference step. This might be solved when we'll rewrite the lookup mechanism, since right now it's scattered all over the place.

```
#!python

from astroid.test_utils import extract_node
n = extract_node('''

def test(k):
(k for k in __(dict(**k)))
''')
print(next(n.infer()))
```

---
- Bitbucket: https://bitbucket.org/logilab/astroid/issue/264

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the provided extract_node reproduction and trace inference for the generator comprehension and dict(**k), focusing on the scattered name-lookup mechanism described in the issue. Done means the example no longer reaches a RuntimeError from recursive inference; use the reproduction to verify the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.