[New-bugs-announce] [issue43186] Recursive call causes core dump in assertRaises

Yang Feng report at bugs.python.org
Wed Feb 10 04:14:27 EST 2021


New submission from Yang Feng <charles.fy at foxmail.com>:

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")
+++++++++++++++++++++++++++++++++++++++++

----------
components: Library (Lib)
messages: 386764
nosy: CharlesFengY
priority: normal
severity: normal
status: open
title: Recursive call causes core dump in assertRaises
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43186>
_______________________________________


More information about the New-bugs-announce mailing list