Skip to content

Relax getrefcount assertions for Python 3.14 compatibility - #4

Closed
manzt wants to merge 1 commit into
mainfrom
push-yxusyvtszmvs
Closed

manzt wants to merge 1 commit into
mainfrom
push-yxusyvtszmvs

Conversation

@manzt

@manzt manzt commented Oct 13, 2025

Copy link
Copy Markdown
Collaborator

Python 3.14 introduced borrowed references optimization (LOAD_FAST_BORROW opcodes) which avoids incrementing refcounts for temporary stack references. This causes sys.getrefcount() to return lower values than in 3.13.

Change all sys.getrefcount(obj) == N assertions to <= N to work across both versions while still catching memory leaks.

Python 3.14 introduced borrowed references optimization
(`LOAD_FAST_BORROW` opcodes) which avoids incrementing refcounts for
temporary stack references. This causes `sys.getrefcount()` to return
lower values than in 3.13.

Change all `sys.getrefcount(obj) == N` assertions to `<= N` to work
across both versions while still catching memory leaks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants