Issue 43186: Recursive call causes core dump in assertRaises
In following teststr.py, class MyString is nestedly instanced in method __getattr__(). This script will lead to a "core dump" in Python interpreter. My Python version is 3.9.1 and my operating system is Ubuntu 16.04.
teststr.py
+++++++++++++++++++++++++++++++++++++++++++
class StrError(str):
pass
class MyString:
def __init__(self, istr):
self.__mystr__ = istr
def __getattr__(self, content):
with self:
return MyString(getattr(self.__mystr__, content))
def __setattr__(self, content, sstr):
setattr(self.__mystr__, content)
def __enter__(self):
return self
def __exit__(self, exc_type, exc_val, exc_tb):
raise StrError(self.__mystr__)
return True
MyString("hello")
+++++++++++++++++++++++++++++++++++++++++