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

RecursionError: maximum recursion depth exceeded while calling a Python object #3318

Closed
ema-ava opened this issue Dec 23, 2019 · 11 comments
Closed

Comments

@ema-ava
Copy link

ema-ava commented Dec 23, 2019

Steps to reproduce

demo.py:


import pandas as pd

def _postprocess_recorded_data(psu_gun_imon_df):
    ab = pd.to_datetime(psu_gun_imon_df['Date UTC'])
    date_utc = ab.dt #.round('S')
    return date_utc.round('S')

used a lintme.sh script to lint it:

#!/bin/bash
set -e
set -x

pylint \
       --rcfile=${PYLINTRC:-${CONDA_PREFIX}/share/ims/pylintrc} \
       --load-plugins=site_python.pylint_checkers,pylint.extensions.check_docs,pylint.extensions.mccabe \
       demo.py'

Current behavior

./lintme.sh
RecursionError: maximum recursion depth exceeded while calling a Python object

Expected behavior

No linting issues

pylint --version output

pylint 2.4.4
astroid 2.3.3
Python 3.7.3

@twmr
Copy link
Contributor

twmr commented Dec 23, 2019

I think this one is a duplicate of #3245.

@twmr
Copy link
Contributor

twmr commented Jan 11, 2020

Nope, #3245 didn't fix this issue.

The shell script provided by @ema-ava is not really needed to reproduce the issue.
I've just verified that the issue still persists with the master branches of astroid & pylint.

import pandas as pd

def get_date(data):
    date_utc = pd.to_datetime(data['Date UTC']).dt
    return date_utc.round('S')
$  pylint --version                                                                                                                                                    
pylint 2.5.0-dev1
astroid 2.4.0
Python 3.7.6 | packaged by conda-forge | (default, Jan  7 2020, 22:33:48) 
[GCC 7.3.0]

stderr of pylint issue3318.py:

Traceback (most recent call last):
  File "/home/thomas/miniconda/envs/py37/bin/pylint", line 7, in <module>
    exec(compile(f.read(), __file__, 'exec'))
  File "/home/thomas/gitrepos/pylint/bin/pylint", line 4, in <module>
    run_pylint()
  File "/home/thomas/gitrepos/pylint/pylint/__init__.py", line 23, in run_pylint
    PylintRun(sys.argv[1:])
  File "/home/thomas/gitrepos/pylint/pylint/lint.py", line 1770, in __init__
    linter.check(args)
  File "/home/thomas/gitrepos/pylint/pylint/lint.py", line 980, in check
    self._check_files(self.get_ast, self._iterate_file_descrs(files_or_modules))
  File "/home/thomas/gitrepos/pylint/pylint/lint.py", line 1009, in _check_files
    self._check_file(get_ast, check_astroid_module, name, filepath, modname)
  File "/home/thomas/gitrepos/pylint/pylint/lint.py", line 1035, in _check_file
    check_astroid_module(ast_node)
  File "/home/thomas/gitrepos/pylint/pylint/lint.py", line 1168, in check_astroid_module
    ast_node, walker, rawcheckers, tokencheckers
  File "/home/thomas/gitrepos/pylint/pylint/lint.py", line 1212, in _check_astroid_module
    walker.walk(ast_node)
  File "/home/thomas/gitrepos/pylint/pylint/utils/ast_walker.py", line 77, in walk
    self.walk(child)
  File "/home/thomas/gitrepos/pylint/pylint/utils/ast_walker.py", line 77, in walk
    self.walk(child)
  File "/home/thomas/gitrepos/pylint/pylint/utils/ast_walker.py", line 77, in walk
    self.walk(child)
  File "/home/thomas/gitrepos/pylint/pylint/utils/ast_walker.py", line 74, in walk
    callback(astroid)
  File "/home/thomas/gitrepos/pylint/pylint/checkers/typecheck.py", line 895, in visit_attribute
    inferred = list(node.expr.infer())
  File "/home/thomas/gitrepos/astroid/astroid/decorators.py", line 141, in raise_if_nothing_inferred
    yield from generator
  File "/home/thomas/gitrepos/astroid/astroid/decorators.py", line 95, in wrapped
    res = next(generator)
  File "/home/thomas/gitrepos/astroid/astroid/inference.py", line 229, in infer_call
    yield from callee.infer_call_result(caller=self, context=callcontext)
  File "/home/thomas/gitrepos/astroid/astroid/scoped_nodes.py", line 1681, in infer_call_result
    yield from returnnode.value.infer(context)
  File "/home/thomas/gitrepos/astroid/astroid/util.py", line 160, in limit_inference
    yield from islice(iterator, size)
  File "/home/thomas/gitrepos/astroid/astroid/context.py", line 113, in cache_generator
    for result in generator:
  File "/home/thomas/gitrepos/astroid/astroid/decorators.py", line 141, in raise_if_nothing_inferred
    yield from generator
....
RecursionError: maximum recursion depth exceeded

@redotics
Copy link

Hey Dear all,

I think this is a regression problem on Astroid side. It does not make recursion error when using astroid 2.2.5 as @netoarmando mentioned in #3245

Tested file: /tmp/pylint_error.py

import pandas as pd

def get_date(data):
    date_utc = pd.to_datetime(data['Date UTC']).dt
    return date_utc.round('S')

I get the same recursion error as you @Thisch with that set-up:

# pylint --version
pylint 2.4.4
astroid 2.3.3
Python 3.7.4 (default, Aug 13 2019, 20:35:49) 
[GCC 7.3.0]

Also with that following set-up (previous version of pylint):

# pylint --version
pylint 2.3.1
astroid 2.3.3
Python 3.7.4 (default, Aug 13 2019, 20:35:49) 
[GCC 7.3.0]

But recursion error does not occur with previous version of astroid 2.2.5:

#  pylint --version
pylint 2.3.1
astroid 2.2.5
Python 3.7.4 (default, Aug 13 2019, 20:35:49) 
[GCC 7.3.0]

For which I happily get:

# pylint /tmp/pylint_error.py
************* Module pylint_error
/tmp/pylint_error.py:1:0: C0111: Missing module docstring (missing-docstring)
/tmp/pylint_error.py:3:0: C0111: Missing function docstring (missing-docstring)

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

@twmr
Copy link
Contributor

twmr commented Jan 15, 2020

Thx @redsharpbyte for triaging this issue.
Sry, I should have mentioned in my previous comment that I already knew that downgrading astroid solved the problem. IMO the next step is to bisect the commit in astroid that lead to this regression. I guess that I have to write a simple script for this that does not depend on pylint but only the astroid API. Can someone help me with writing this script?

@netoarmando
Copy link

Hello @Thisch, that regression started after pylint-dev/astroid@79d5a3a and it was already fixed by this PR: pylint-dev/astroid#733.

@redotics
Copy link

Thanks for the details. That's advanced :)

Is the next release/tag of Astroid already planned ?
That would be astroid-2.3.4 I suppose
The first of this Happy New Year ! :)

@PCManticore
Copy link
Contributor

This seems to have been fixed by pylint-dev/astroid#733.

@dickreuter
Copy link
Contributor

Having maximum recursions with pylint 2.3.1, 2.4.4. and also 2.6. Any suggestions on what I can do are greatly appreciated.

@hippo91
Copy link
Contributor

hippo91 commented Dec 20, 2020

@dickreuter while waiting the bug are fixed, you may try to rise the value of the python recursion limit.

@b-long
Copy link

b-long commented Jan 20, 2021

I'm really interested in #3318 (comment) .

Are new astroid and pylint releases expected?

@hippo91
Copy link
Contributor

hippo91 commented Jan 23, 2021

@b-long yes new releases are expected soon. I can't tell more precisely when though.

jepler added a commit to jepler/wwvbpy that referenced this issue Feb 2, 2021
jepler added a commit to jepler/wwvbpy that referenced this issue Feb 3, 2021
geugenm pushed a commit to geugenm/polaris-ml-playground that referenced this issue Oct 1, 2024
This fixes a problem we've encountered where pylint tests fail with
this error:

	RecursionError: maximum recursion depth exceeded in comparison

The bug appears to be this one:

	pylint-dev/pylint#3318

For the record, this was extremely hard to track down.  The error
appeared erratically, as there appears to be some caching (and
invalidation + recreation) of tox environments and/or packages that
feeds into this.

We can revisit the version pinning in the future; at the moment,
there's no other motivation for the pinning.

Signed-off-by: Hugh Brown (Saint Aardvark the Carpeted) <aardvark@saintaardvarkthecarpeted.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants