Author vstinner
Recipients python-dev, serhiy.storchaka, vstinner
Date 2015-10-01.10:55:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1443696904.09.0.831310175726.issue25274@psf.upfronthosting.co.za>
In-reply-to
Content
Serhiy wrote:
> This message looks confusing to me. 2 > 1, isn't?
> The dependency of min_limit from new_limit is not monotonic: (...)

Ok, now I'm confused too :-)

First of all, I propose to change the exception type to RecursionError because it's really strange to get a ValueError depending on the current recursion depth.

I would prefer to have an hardcoded minimum limit instead of a minimum depending on the current recursion depth, but I'm not sure that it's technically possible according to current constraints in CPython.

Updated patch (version 3) doesn't mention the computed "minimum limit" in the error message since it's hard to compute it for the user (and even for me :-)). For the user, it's hard to estimate (or compute) the current recursion depth.

Updated example:

$ ./python -c 'import sys; sys.setrecursionlimit(0)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ValueError: recursion limit must be greater or equal than 1

$ ./python -c 'import sys; sys.setrecursionlimit(1)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RecursionError: cannot set recursion limit to 1 at the recursion depth 1: the limit is too low

$ ./python -c 'import sys; sys.setrecursionlimit(2)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RecursionError: cannot set recursion limit to 2 at the recursion depth 1: the limit is too low

$ ./python -c 'import sys; sys.setrecursionlimit(3)'

(A limit of 3 is valid.)
History
Date User Action Args
2015-10-01 10:55:04vstinnersetrecipients: + vstinner, python-dev, serhiy.storchaka
2015-10-01 10:55:04vstinnersetmessageid: <1443696904.09.0.831310175726.issue25274@psf.upfronthosting.co.za>
2015-10-01 10:55:04vstinnerlinkissue25274 messages
2015-10-01 10:55:03vstinnercreate