notebook
                                
                                 notebook copied to clipboard
                                
                                    notebook copied to clipboard
                            
                            
                            
                        The code causes the kernel to die due to infinite recursion
Describe the bug A bug in the code caused the kernel to die
To Reproduce Steps to reproduce the behavior:
- Using the following code can cause kernel death
class A:
    def __init__(self, data) -> None:
        self.data = data
    def __bool__(self) -> bool:
        return bool(a)
a = A("Test")
bool(a)
Expected behavior
- Python reports errors due to infinite recursion
 
Screenshots

Desktop (please complete the following information):
- OS: Windows 11 22H2
- Browser: Edge
- Version: 👇👇👇


Thanks for reporting @CoolPlayLin. A similar issue has previously been reported as well https://github.com/jupyter/notebook/issues/2648.
You probably didn't get what I mean @RRosio I'm focusing on kernel bugs
After running the above code, Python will prompt an error, but Jupyter notebook is the kernel directly dead @RRosio
@RRosio
@CoolPlayLin Thank you for clarifying this issue. This issue has been accepted but no one is actively working on it at the moment. If you'd like to look into this issue, we'd welcome a pull request!
I had this same issue. My code that caused it to crash:
class Bug:
    def __post_init__(self): # NOTE: Should be __init__
        self._config = {"bug": True}
    def __getattr__(self, name):
        return self._config[name]
b = Bug()
b.bug
Running this code in the Python interpreter gives the following:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 5, in __getattr__
  File "<stdin>", line 5, in __getattr__
  File "<stdin>", line 5, in __getattr__
  [Previous line repeated 996 more times]
RecursionError: maximum recursion depth exceeded
Note that the following code, when run in a Jupyter Notebook, generates a recursion error as expected, without killing the kernel.
def inf_rec():
    inf_rec()
inf_rec()
Any update?