Skip to content

Recursive call causes core dump in assertRaises #87352

Closed

Description

@CharlesFengY
BPO 43186
Nosy @CharlesFengY
Superseder
  • bpo-43185: <unittest> AssertRaises() causes core dump in handling recursion
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-02-13.04:52:47.179>
    created_at = <Date 2021-02-10.09:14:27.950>
    labels = ['library', '3.9']
    title = 'Recursive call causes core dump in assertRaises'
    updated_at = <Date 2021-02-13.04:53:58.135>
    user = 'https://github.com/CharlesFengY'

    bugs.python.org fields:

    activity = <Date 2021-02-13.04:53:58.135>
    actor = 'terry.reedy'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-02-13.04:52:47.179>
    closer = 'terry.reedy'
    components = ['Library (Lib)']
    creation = <Date 2021-02-10.09:14:27.950>
    creator = 'CharlesFengY'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 43186
    keywords = []
    message_count = 1.0
    messages = ['386764']
    nosy_count = 1.0
    nosy_names = ['CharlesFengY']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '43185'
    type = None
    url = 'https://bugs.python.org/issue43186'
    versions = ['Python 3.9']

    Activity

    1. CharlesFengY commented on Feb 10, 2021

      CharlesFengYmannequin
      MannequinAuthor

      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")
      +++++++++++++++++++++++++++++++++++++++++
    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Feb 10, 2021
    3. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.9 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directory

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions