[issue41318] Better error message of "Cannot recover from stack overflow."

2020-07-16 Thread Heyi Tang


New submission from Heyi Tang :

Is it possible to add more detailed message for the error "Cannot recover from 
stack overflow"?
Something like "Cannot recover from stack overflow, it may be caused by 
catching a RecursionError but reaching the limit again before properly handling 
it."
Maybe the detailed design in 
https://github.com/python/cpython/blob/master/Include/ceval.h#L48 could also be 
shown to the developer?

It is hard to understand what happened only with the message "Cannot recover 
from stack overflow".

I hit the error because I write the code as following:
@some_logger
def f():
return f()
try:
  f()
except RecursionError:
  print("Recursion Error is raised!")

And it took me a lot of time to figure out why RecursionError is not raised but 
the "Fatal Python error" is shown.
Finally I realized that the problem is that the following code piece in 
"some_logger" (Which is an internal library provided by others) caught the 
exception and make tstate->overflowed=1.

def some_logger(func):
@functools.wraps(func)
def new_func(*args, **kwargs):
try:
# Unfortunately this code hit RecursionError and catched it
logger.info(some_message)
except Exception as e:
pass # Avoid affecting user function
return func(*args, **kwargs)
return new_func

So I think it might be better to provide more information to the developer that 
"Cannot recover" means that "RecursionError is caught and stack overflow 
again." and hint user to know the design of _Py_EnterRecursiveCall.

--
components: Interpreter Core
messages: 373796
nosy: th
priority: normal
severity: normal
status: open
title: Better error message of "Cannot recover from stack overflow."
type: enhancement
versions: Python 3.10

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



[issue41318] Better error message of "Cannot recover from stack overflow."

2020-07-19 Thread Heyi Tang


Change by Heyi Tang :


--
versions: +Python 3.8 -Python 3.10

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



[issue41318] Better error message of "Cannot recover from stack overflow."

2020-07-19 Thread Heyi Tang


Change by Heyi Tang :


--
type: enhancement -> behavior

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



[issue41318] Better error message of "Cannot recover from stack overflow."

2020-07-19 Thread Heyi Tang


Change by Heyi Tang :


--
versions: +Python 3.10, Python 3.5, Python 3.6, Python 3.7, Python 3.9

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



[issue41318] Better error message of "Cannot recover from stack overflow."

2020-07-28 Thread Heyi Tang


Change by Heyi Tang :


--
keywords: +patch
pull_requests: +20798
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/21655

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