Message386764
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")
+++++++++++++++++++++++++++++++++++++++++ |
|
Date |
User |
Action |
Args |
2021-02-10 09:14:28 | CharlesFengY | set | recipients:
+ CharlesFengY |
2021-02-10 09:14:27 | CharlesFengY | set | messageid: <1612948467.97.0.883928038728.issue43186@roundup.psfhosted.org> |
2021-02-10 09:14:27 | CharlesFengY | link | issue43186 messages |
2021-02-10 09:14:27 | CharlesFengY | create | |
|