Skip to content

Tracing a class that defines a custom __class__ appears to remove said property under certain circumstances #98148

@ionelmc

Description

@ionelmc

Tested on 3.7, 3.8, 3.9 and 3.10

It appears that using super() in the class makes the class behave differently when traced:

import sys

def tracer(frame, event, _):
    return tracer
sys.settrace(tracer)


class Foo:
    pass

class FancyFoo:
    def bug(self):
        super()

    @property
    def __class__(self):
        return Foo

assert isinstance(FancyFoo(), Foo)

Remove either the def bug or the settrace call and the assertion passes.

Ref nedbat/coveragepy#1382.

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions