This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: maximum recursion depth exceeded in lib\pstats.py
Type: crash Stage:
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Adam.Bielański, georg.brandl
Priority: normal Keywords: patch

Created on 2010-10-21 15:50 by Adam.Bielański, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pstats.patch Adam.Bielański, 2010-10-21 15:50 Patch that makes add() iterative, not recursive
Messages (2)
msg119311 - (view) Author: Adam Bielański (Adam.Bielański) * Date: 2010-10-21 15:50
There's a bug in module lib\pstats.py, line 150. 

Let me paste a little piece of surrounding code:

    class Stats:
      (....)
        def add(self, *arg_list):
            if not arg_list: return self
            if len(arg_list) > 1: self.add(*arg_list[1:])  #Line 150, the problem is right here!
            other = arg_list[0]
            (... do some processing with first item from arg_list ...)

This is the code for adding profiling stats from multiple files (names are on arg_list) so that they can be displayed in cumulated and readable form.

As you can see it chops off the first item from the list and then uses recursion to process the rest of it. It's no wonder then that when you profiled a little too many function calls, you're bound to see RuntimeError with 'maximum recursion depth exceeded' message when you try using this. IMO this should be done with iteration instead, like:

        def add(self, *arg_list):
            if not arg_list: return self
            for other in arg_list: #Preserved variable name only for sake of comparison with previous snippet
                (... do some processing with each item from arg_list, merging results in some rightful manner ...)


You can find a patch for this issue in the attachment.
msg119363 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-10-22 06:28
Thanks, fixed in r85787.
History
Date User Action Args
2022-04-11 14:57:07adminsetgithub: 54375
2010-10-22 06:28:11georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg119363

resolution: fixed
2010-10-21 15:50:13Adam.Bielańskicreate