New submission from Yang Feng <charles...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue43186>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to