Skip to content

__del__ method is not called #985

Open
@jameslan

Description

@jameslan

Steps to Reproduce

If we have a class with __del__ method:

import sys


class Foo:
    def __init__(self, name):
        self.name = name

    def __del__(self):
        sys.stdout.write(self.name + '\n')

Running the following statements with CPython,

def func():
    foo = Foo('Foo 1')
    bar = Foo('Foo 2')
    del bar

func()
foo = Foo('Foo 3')
foo = Foo('Foo 4')

[Expected behavior:]
will get output

Foo 2
Foo 1
Foo 3
Foo 4

[Actual behavior:]
But running with IronPython, there's nothing output.

This blocks #938. FileIO, TextIOWrapper etc classes have finalizer (defined in their base class _IOBase) calling close(). But the finalizer is never called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions