Ask Your Question

Revision history [back]

This certainly is weird. I think you have an indentation problem in your post, but that doesn't seem to be the problem.

The following is slightly simpler, but also prints the error message for me. (It also prints the error message when I use except RuntimeError)

def number(expr):
    try:    
        n = N(expr)
    except:
        n = 0
    return n

Note, by contrast, that the following works without problem (no error message printed):

def divide(n):
    try:
        r = 1/n
    except ZeroDivisionError:
        r = Infinity
    return r

So it seems this is a bug with the recursion depth RuntimeError . . .

This certainly is weird. I think you have an indentation problem in your post, but that doesn't seem to be the problem.

The following is slightly simpler, but also prints the error message for me. (It also prints the error message when I use except RuntimeError)

def number(expr):
    try:    
        n = N(expr)
    except:
        n = 0
    return n

Note, by contrast, that the following works without problem (no error message printed):

def divide(n):
    try:
        r = 1/n
    except ZeroDivisionError:
        r = Infinity
    return r

So it seems this is a bug with the recursion depth RuntimeError . . .


UPDATE: Based on the discussion, I've filed a ticked for this: #10774