def raiseMemError(): try: raise_memoryerror() except MemoryError as e: tb = e.__traceback__ else: self.fail("Should have raises a MemoryError") return traceback.format_tb(tb)
def inner(): nonlocal wr c = C() wr = weakref.ref(c) raise_memoryerror()