[issue42951] Random and infinite loop in dealing with recursion error for "try-except "

2021-01-21 Thread Mark Shannon


Change by Mark Shannon :


--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42951] Random and infinite loop in dealing with recursion error for "try-except "

2021-01-21 Thread Mark Shannon


Mark Shannon  added the comment:

Yes, see PEP 651

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42951] Random and infinite loop in dealing with recursion error for "try-except "

2021-01-19 Thread Xinmeng Xia


Xinmeng Xia  added the comment:

oh,I see. By the way, I set the argument of sys.setrecursionlimit to 10 in 
this program and a segmentation fault is reported. Is that normal?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42951] Random and infinite loop in dealing with recursion error for "try-except "

2021-01-19 Thread Mark Shannon


Mark Shannon  added the comment:

Try setting the recursion limit to 10 or so and it should terminate.

The reason ctrl-C doesn't work is that you are catching the KeyboardInterrupt. 
Never use a plain `except:`, use `except Exception:`

--
nosy: +Mark.Shannon

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42951] Random and infinite loop in dealing with recursion error for "try-except "

2021-01-18 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Funny. But the output is not random. You can generate the sequence of letters 
by the following simple loop:

s = ''
for i in range(n):
s = f'a{s}b{s}'

The length of this sequence is 2*(2**n-1). Finally, your code will raise a 
non-silenced RecursiveError, but it will just take some time (for printing 
around 2**1000 letters).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42951] Random and infinite loop in dealing with recursion error for "try-except "

2021-01-18 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42951] Random and infinite loop in dealing with recursion error for "try-except "

2021-01-17 Thread Xinmeng Xia


New submission from Xinmeng Xia :

In issue 42500, recursive calls in "Try-except" are resolved. This PR has fixed 
the crashes of some programs, such as program 1. And the core dump error is 
replaced with RecursiveError.  
However, program 2 will not report a RecursiveError. The program will fall into 
an infinite loop. Even "Ctrl C" cannot stop the infinite loop. I try to track 
the execution of this program and insert "print" information(see program 3). 
The output seems random in execution between try branch and except branch!  I 
think this is a new bug after fixing 42500. I believe the program should also 
return RecursiveError.


Program 1
=== 
def foo():
try:
1/0
except:
foo()
foo()


Program 2

def foo():
try:
foo()
except:
foo()
foo()



Program 3

def foo():
try:
print("a")
foo()
except:
print("b")
foo()

foo()

Output for program3( unexpected infinite random loop. ):
..bbbbabbaabbabbaaabbabbaabbabbbbabbaabbabbaaabbabbaabbabbbbabbaabbabbaaabbabbaabbabbabbabbaabbabbaaabbabbaabbabbbbabbaabbabbaaabbabbaabbabbaabbabbaabbabbaaabbabbaabbabbbb..

>>python -V
Python 3.10.0a4

--
components: Interpreter Core
messages: 385171
nosy: xxm
priority: normal
severity: normal
status: open
title: Random and infinite loop in dealing with recursion error for "try-except 
"
type: behavior
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com