New submission from Xinmeng Xia <xi...@smail.nju.edu.cn>:

Seeing the following programs, we try to catch a recursive call error in 
exception handling.  The behaviors between Python 3.10.0a4 and older version 
are inconsistent. The outputs are attached in the end. The output on Python 
3.10.0a4 is very weird. Two "print statements" lie in same "except" block to 
print "exception info" and a string "kk". "kk" is printed once while "exception 
info" is printed twice! I think a bug probably exists in Python 3.10.0a4 parser 
on handling stacks. 


=========================
def foo(c):
         try:
             c = c + 1
             print("ss"+str(c))
             foo(c)
         except Exception as e:
             print(str(e))
             print("kk")
         print(c)
c = 0
foo(c)
=========================

Output in Python 3.10.0a2 and older version(expected)
------------------------------------------------------------------------
ss1
ss2
....
ss996
maximum recursion depth exceeded while calling a Python object
kk
996
995
......
3
2
1
------------------------------------------------------------------------

Output in Python 3.10.0a4 (unexpected)
------------------------------------------------------------------------
ss1
ss2
....
ss996
maximum recursion depth exceeded while calling a Python object
maximum recursion depth exceeded while calling a Python object
kk
995
......
3
2
1
------------------------------------------------------------------------

----------
components: Interpreter Core
messages: 385170
nosy: xxm
priority: normal
severity: normal
status: open
title: Incorrect exception behavior in handling recursive call.
type: behavior
versions: Python 3.10

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42950>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to