Skip to content

Not just another 'maximum recursion depth exceeded while calling a Python object' #3245

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

Closed
stanislavlevin opened this issue Nov 15, 2019 · 2 comments · Fixed by pylint-dev/astroid#733
Labels
Bug 🪲 Crash 💥 A bug that makes pylint crash

Comments

@stanislavlevin
Copy link
Contributor

There is a weird behavior of Pylint regarding the following example:
pylint_repr.py.txt

Note: to run - pytest -p pytester test_pylint.py -v

The result would be:

...
test_pylint.py::test_pylint[0] PASSED                                                   [ 25%]
test_pylint.py::test_pylint[1] FAILED                                                   [ 50%]
test_pylint.py::test_pylint[2] FAILED                                                   [ 75%]
test_pylint.py::test_pylint[3] PASSED                                                   [100%]
...

========================================== FAILURES ===========================================
_______________________________________ test_pylint[1] ________________________________________

code_dir = <Testdir local('/tmp/pytest-of-root/pytest-22/test_pylint1')>, jobs = 1

    @pytest.mark.parametrize("jobs", range(4))
    def test_pylint(code_dir, jobs):
        cmd = [
            sys.executable,
            "-m", "pylint",
            "-j", str(jobs),
            os.path.join(str(code_dir), "sub_a"),
            os.path.join(str(code_dir), "sub_c"),
        ]
        result = code_dir.run(*cmd)
>       assert result.ret == 0
E       assert 1 == 0
E         -1
E         +0

 /freeipa/test/test_pylint.py:61: AssertionError
------------------------------------ Captured stdout call -------------------------------------
running: /usr/bin/python3 -m pylint -j 1 /tmp/pytest-of-root/pytest-22/test_pylint1/sub_a /tmp/pytest-of-root/pytest-22/test_pylint1/sub_c
     in: /tmp/pytest-of-root/pytest-22/test_pylint1
------------------------------------ Captured stderr call -------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/astroid/__init__.py", line 91, in _inference_tip_cached
    return iter(_cache[func, node])
KeyError: (<function register_builtin_transform.<locals>._transform_wrapper at 0x7f0c46279320>, <Call l.8 at 0x7f0c45996590>)
...

RecursionError: maximum recursion depth exceeded while calling a Python object
_______________________________________ test_pylint[2] ________________________________________

code_dir = <Testdir local('/tmp/pytest-of-root/pytest-22/test_pylint2')>, jobs = 2

    @pytest.mark.parametrize("jobs", range(4))
    def test_pylint(code_dir, jobs):
        cmd = [
            sys.executable,
            "-m", "pylint",
            "-j", str(jobs),
            os.path.join(str(code_dir), "sub_a"),
            os.path.join(str(code_dir), "sub_c"),
        ]
        result = code_dir.run(*cmd)
        assert result.ret == 0
        out = result.stderr.str()
>       assert not out
E       assert not "internal error with sending report for module ['/tmp/pytest-of-root/pytest-22/test_pylint2/sub_c/mod_c.py']\nmaximum recursion depth exceeded while calling a Python object"

/freeipa/test/test_pylint.py:63: AssertionError
------------------------------------ Captured stdout call -------------------------------------
running: /usr/bin/python3 -m pylint -j 2 /tmp/pytest-of-root/pytest-22/test_pylint2/sub_a /tmp/pytest-of-root/pytest-22/test_pylint2/sub_c
     in: /tmp/pytest-of-root/pytest-22/test_pylint2

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

------------------------------------ Captured stderr call -------------------------------------
internal error with sending report for module ['/tmp/pytest-of-root/pytest-22/test_pylint2/sub_c/mod_c.py']
maximum recursion depth exceeded while calling a Python object
============================= 2 failed, 2 passed

Note:

nproc --all
4

So, there are at least two problems:

  1. RecursionError
  2. results depend on parallelism factor:
    1 - exits with result code 1
    2 - exit with result code 0, but an error is shown in stderr
    3 - 'all is fine'

I'm in a hopeless situation.
Multiprocess Pylint is compromised, while the single-mode is broken for me.

Pylint infos I've checked:

pylint 2.3.1                                                               
astroid 2.3.0                                                                   
Python 3.7.5
pylint 2.4.3
astroid 2.3.3
Python 3.7.4
@netoarmando
Copy link

I looked into this and I could reproduce what @stanislavlevin experienced.

As the log shows it's an astroid issue and It's only affecting >=2.3.0 releases.

Running the reproducer with astroid==2.2.5 I got:

======================== test session starts ========================
platform linux -- Python 3.7.4, pytest-4.6.6, py-1.8.0, pluggy-0.12.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /root
collected 4 items                                                   

pylint_repr.py::test_pylint[0] PASSED                         [ 25%]
pylint_repr.py::test_pylint[1] PASSED                         [ 50%]
pylint_repr.py::test_pylint[2] PASSED                         [ 75%]
pylint_repr.py::test_pylint[3] PASSED                         [100%]

===================== 4 passed in 2.72 seconds ======================

I tried several commits from master branch and this issue starts to appear after pylint-dev/astroid@79d5a3a.

@PCManticore should this be also reported in astroid's issue tracker?

@PCManticore
Copy link
Contributor

Yeah, feel free to open it up in astroid as well.

stanislavlevin added a commit to stanislavlevin/astroid that referenced this issue Dec 22, 2019
Under the certain circumstances invocation of `safe_infer` helper
without a proper context leads to an infinite recursion.

Related: pylint-dev/pylint#3245
Signed-off-by: Stanislav Levin <[email protected]>
stanislavlevin added a commit to stanislavlevin/astroid that referenced this issue Dec 23, 2019
Under the certain circumstances invocation of `safe_infer` helper
without a proper context leads to an infinite recursion.

Related: pylint-dev/pylint#3245
Signed-off-by: Stanislav Levin <[email protected]>
stanislavlevin added a commit to stanislavlevin/astroid that referenced this issue Dec 23, 2019
As of now, the transformation of builtin containers which
members, in turn, are containers relies on `safe_infer`
helper. `safe_infer` tries to infer the node to get its
values. Doing this without a cache containing a previously
inferred nodes lead to infinite recursion, for example, on
resolving a class attribute.

Note: this doesn't help to infer a class attribute by itself
is such a case, but prevents crash.

Closes: pylint-dev/pylint#3245
Signed-off-by: Stanislav Levin <[email protected]>
PCManticore pushed a commit to pylint-dev/astroid that referenced this issue Dec 23, 2019
As of now, the transformation of builtin containers which
members, in turn, are containers relies on `safe_infer`
helper. `safe_infer` tries to infer the node to get its
values. Doing this without a cache containing a previously
inferred nodes lead to infinite recursion, for example, on
resolving a class attribute.

Note: this doesn't help to infer a class attribute by itself
is such a case, but prevents crash.

Closes: pylint-dev/pylint#3245
Signed-off-by: Stanislav Levin <[email protected]>
stanislavlevin added a commit to stanislavlevin/freeipa that referenced this issue Feb 11, 2020
This is the first time running Pylint-2.4 over the whole IPA codebase.
```
Pylint on /usr/bin/python is running, please wait ...
internal error with sending report for module ['ipaserver/plugins/serverroles.py']
maximum recursion depth exceeded while calling a Python object
************* Module ipatests.test_integration.base
ipatests/test_integration/base.py:84: [W0125(using-constant-test), IntegrationTest.install] Using a conditional statement with a constant value)
************* Module ipaserver.install.ipa_cacert_manage
ipaserver/install/ipa_cacert_manage.py:522: [R1724(no-else-continue), CACertManage.delete] Unnecessary "elif" after "continue")
```

The latest Pylint (via the Tox task) checks only:
```
{envsitepackagesdir}/ipaclient \
{envsitepackagesdir}/ipalib \
{envsitepackagesdir}/ipapython
```

, while the distro-Pylint runs over all project but it is not fresh.
That's why these warnings/errors weren't exposed before now.

Concerning `internal error`: a fix was accepted by upstream:
pylint-dev/pylint#3245, but wasn't released yet.
Until that is done, Pylint just warns.

Related: https://pagure.io/freeipa/issue/8116
Signed-off-by: Stanislav Levin <[email protected]>
stanislavlevin added a commit to stanislavlevin/freeipa that referenced this issue Feb 11, 2020
This is the first time running Pylint-2.4 over the whole IPA codebase.
```
Pylint on /usr/bin/python is running, please wait ...
internal error with sending report for module ['ipaserver/plugins/serverroles.py']
maximum recursion depth exceeded while calling a Python object
************* Module ipatests.test_integration.base
ipatests/test_integration/base.py:84: [W0125(using-constant-test), IntegrationTest.install] Using a conditional statement with a constant value)
************* Module ipaserver.install.ipa_cacert_manage
ipaserver/install/ipa_cacert_manage.py:522: [R1724(no-else-continue), CACertManage.delete] Unnecessary "elif" after "continue")
```

The latest Pylint (via the Tox task) checks only:
```
{envsitepackagesdir}/ipaclient \
{envsitepackagesdir}/ipalib \
{envsitepackagesdir}/ipapython
```

, while the distro-Pylint runs over all project but it is not fresh.
That's why these warnings/errors weren't exposed before now.

Concerning `internal error`: a fix was accepted by upstream:
pylint-dev/pylint#3245, but wasn't released yet.
Until that is done, Pylint just warns.

Related: https://pagure.io/freeipa/issue/8116
Signed-off-by: Stanislav Levin <[email protected]>
stanislavlevin added a commit to stanislavlevin/freeipa that referenced this issue Feb 11, 2020
This is the first time running Pylint-2.4 over the whole IPA codebase.
```
Pylint on /usr/bin/python is running, please wait ...
internal error with sending report for module ['ipaserver/plugins/serverroles.py']
maximum recursion depth exceeded while calling a Python object
************* Module ipatests.test_integration.base
ipatests/test_integration/base.py:84: [W0125(using-constant-test), IntegrationTest.install] Using a conditional statement with a constant value)
************* Module ipaserver.install.ipa_cacert_manage
ipaserver/install/ipa_cacert_manage.py:522: [R1724(no-else-continue), CACertManage.delete] Unnecessary "elif" after "continue")
```

The latest Pylint (via the Tox task) checks only:
```
{envsitepackagesdir}/ipaclient \
{envsitepackagesdir}/ipalib \
{envsitepackagesdir}/ipapython
```

, while the distro-Pylint runs over all project but it is not fresh.
That's why these warnings/errors weren't exposed before now.

Concerning `internal error`: a fix was accepted by upstream:
pylint-dev/pylint#3245, but wasn't released yet.
Until that is done, Pylint just warns.

Related: https://pagure.io/freeipa/issue/8116
Signed-off-by: Stanislav Levin <[email protected]>
stanislavlevin added a commit to stanislavlevin/freeipa that referenced this issue Feb 11, 2020
This is the first time running Pylint-2.4 over the whole IPA codebase.
```
Pylint on /usr/bin/python is running, please wait ...
internal error with sending report for module ['ipaserver/plugins/serverroles.py']
maximum recursion depth exceeded while calling a Python object
************* Module ipatests.test_integration.base
ipatests/test_integration/base.py:84: [W0125(using-constant-test), IntegrationTest.install] Using a conditional statement with a constant value)
************* Module ipaserver.install.ipa_cacert_manage
ipaserver/install/ipa_cacert_manage.py:522: [R1724(no-else-continue), CACertManage.delete] Unnecessary "elif" after "continue")
```

The latest Pylint (via the Tox task) checks only:
```
{envsitepackagesdir}/ipaclient \
{envsitepackagesdir}/ipalib \
{envsitepackagesdir}/ipapython
```

, while the distro-Pylint runs over all project but it is not fresh.
That's why these warnings/errors weren't exposed before now.

Concerning `internal error`: a fix was accepted by upstream:
pylint-dev/pylint#3245, but wasn't released yet.
Until that is done, Pylint just warns.

Related: https://pagure.io/freeipa/issue/8116
Signed-off-by: Stanislav Levin <[email protected]>
pull bot pushed a commit to NeatNerdPrime/freeipa that referenced this issue Feb 12, 2020
This is the first time running Pylint-2.4 over the whole IPA codebase.
```
Pylint on /usr/bin/python is running, please wait ...
internal error with sending report for module ['ipaserver/plugins/serverroles.py']
maximum recursion depth exceeded while calling a Python object
************* Module ipatests.test_integration.base
ipatests/test_integration/base.py:84: [W0125(using-constant-test), IntegrationTest.install] Using a conditional statement with a constant value)
************* Module ipaserver.install.ipa_cacert_manage
ipaserver/install/ipa_cacert_manage.py:522: [R1724(no-else-continue), CACertManage.delete] Unnecessary "elif" after "continue")
```

The latest Pylint (via the Tox task) checks only:
```
{envsitepackagesdir}/ipaclient \
{envsitepackagesdir}/ipalib \
{envsitepackagesdir}/ipapython
```

, while the distro-Pylint runs over all project but it is not fresh.
That's why these warnings/errors weren't exposed before now.

Concerning `internal error`: a fix was accepted by upstream:
pylint-dev/pylint#3245, but wasn't released yet.
Until that is done, Pylint just warns.

Related: https://pagure.io/freeipa/issue/8116
Signed-off-by: Stanislav Levin <[email protected]>
Reviewed-By: Christian Heimes <[email protected]>
abbra pushed a commit to abbra/freeipa that referenced this issue Feb 13, 2020
This is the first time running Pylint-2.4 over the whole IPA codebase.
```
Pylint on /usr/bin/python is running, please wait ...
internal error with sending report for module ['ipaserver/plugins/serverroles.py']
maximum recursion depth exceeded while calling a Python object
************* Module ipatests.test_integration.base
ipatests/test_integration/base.py:84: [W0125(using-constant-test), IntegrationTest.install] Using a conditional statement with a constant value)
************* Module ipaserver.install.ipa_cacert_manage
ipaserver/install/ipa_cacert_manage.py:522: [R1724(no-else-continue), CACertManage.delete] Unnecessary "elif" after "continue")
```

The latest Pylint (via the Tox task) checks only:
```
{envsitepackagesdir}/ipaclient \
{envsitepackagesdir}/ipalib \
{envsitepackagesdir}/ipapython
```

, while the distro-Pylint runs over all project but it is not fresh.
That's why these warnings/errors weren't exposed before now.

Concerning `internal error`: a fix was accepted by upstream:
pylint-dev/pylint#3245, but wasn't released yet.
Until that is done, Pylint just warns.

Related: https://pagure.io/freeipa/issue/8116
Signed-off-by: Stanislav Levin <[email protected]>
Reviewed-By: Christian Heimes <[email protected]>
stanislavlevin added a commit to stanislavlevin/freeipa that referenced this issue Mar 13, 2020
This is the first time running Pylint-2.4 over the whole IPA codebase.
```
Pylint on /usr/bin/python is running, please wait ...
internal error with sending report for module ['ipaserver/plugins/serverroles.py']
maximum recursion depth exceeded while calling a Python object
************* Module ipatests.test_integration.base
ipatests/test_integration/base.py:84: [W0125(using-constant-test), IntegrationTest.install] Using a conditional statement with a constant value)
************* Module ipaserver.install.ipa_cacert_manage
ipaserver/install/ipa_cacert_manage.py:522: [R1724(no-else-continue), CACertManage.delete] Unnecessary "elif" after "continue")
```

The latest Pylint (via the Tox task) checks only:
```
{envsitepackagesdir}/ipaclient \
{envsitepackagesdir}/ipalib \
{envsitepackagesdir}/ipapython
```

, while the distro-Pylint runs over all project but it is not fresh.
That's why these warnings/errors weren't exposed before now.

Concerning `internal error`: a fix was accepted by upstream:
pylint-dev/pylint#3245, but wasn't released yet.
Until that is done, Pylint just warns.

Related: https://pagure.io/freeipa/issue/8116
Signed-off-by: Stanislav Levin <[email protected]>
Reviewed-By: Christian Heimes <[email protected]>
stanislavlevin added a commit to stanislavlevin/freeipa that referenced this issue Mar 13, 2020
This is the first time running Pylint-2.4 over the whole IPA codebase.
```
Pylint on /usr/bin/python is running, please wait ...
internal error with sending report for module ['ipaserver/plugins/serverroles.py']
maximum recursion depth exceeded while calling a Python object
************* Module ipatests.test_integration.base
ipatests/test_integration/base.py:84: [W0125(using-constant-test), IntegrationTest.install] Using a conditional statement with a constant value)
************* Module ipaserver.install.ipa_cacert_manage
ipaserver/install/ipa_cacert_manage.py:522: [R1724(no-else-continue), CACertManage.delete] Unnecessary "elif" after "continue")
```

The latest Pylint (via the Tox task) checks only:
```
{envsitepackagesdir}/ipaclient \
{envsitepackagesdir}/ipalib \
{envsitepackagesdir}/ipapython
```

, while the distro-Pylint runs over all project but it is not fresh.
That's why these warnings/errors weren't exposed before now.

Concerning `internal error`: a fix was accepted by upstream:
pylint-dev/pylint#3245, but wasn't released yet.
Until that is done, Pylint just warns.

Related: https://pagure.io/freeipa/issue/8116
Signed-off-by: Stanislav Levin <[email protected]>
Reviewed-By: Christian Heimes <[email protected]>
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.

3 participants