[3.14] change in behaviour in gc.get_referrers(some_local)
Đang mở
@markshannon đang làm issue này rồi.
Từ ngày 16/10/2024.
3.14
triaged
type-bug
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 36k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
Bug report
Bug description:
import gc
async def demo():
class A:
pass
a = A()
print(gc.get_referrers(a))
try:
demo().send(None)
except StopIteration as e:
print(f"{e.value=}")
on 3.11-3.13 this prints:
[]
e.value=None
on 3.14 this prints:
[<coroutine object demo at 0x7d00fff85000>]
e.value=None
this makes gc.get_referrers less useful in detecting cyclic garbage where I'd like to be able to make the assertion that the current frame is the only referrer to an Exception.
the alternative is to hold a weak reference to the object, delete the object and see if the weak reference is dead with the gc disabled. But then I don't get any debug information in my failing test of why the object is still alive.
CPython versions tested on:
3.14, CPython main branch
Operating systems tested on:
Linux
note: @markshannon asked me to open this issue
Linked PRs
- gh-125640
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Đánh giá
Issue này chưa được đánh giá.