[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. 

class StrError(str):

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


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>

More information about the New-bugs-announce mailing list