Tracing a class that defines a custom `__class__` appears to remove said property under certain circumstances
Open
Nobody has claimed this yet.
interpreter-core
type-bug
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 36k
- PR merge metrics
- PR metrics pending
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied Python reproducer, focusing on sys.settrace, super(), and the custom class property. Reproduce the failed assertion across the affected Python versions, then trace the relevant behavior until the assertion remains true under tracing. A regression test should cover the reported combination.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100