Repository navigation
Release encode_lines iterators - #1284
Merged
sobolevn merged 2 commits intoOct 18, 2026
Merged
Conversation
Comment on lines
+369
to
+371
| gc.collect() | ||
| assert len(refs) == 1 | ||
| assert refs[0]() is None |
Member
There was a problem hiding this comment.
@sobolevn I know you don't like manually calling gc things, but I feel like this is fine?
Member
There was a problem hiding this comment.
I don't think that we should have any tests for leaks, we should better use correct tooling for this: memory sanitizers, leak detectors for the whole test suite, etc :)
Contributor
Author
There was a problem hiding this comment.
Thanks @sobolevn, done. I removed the GC-based test and moved the success-path Py_DECREF into the iterator branch, keeping the error cleanup. Rebuilt the extension and all 6,536 local unit tests pass.
sobolevn
reviewed
Oct 18, 2026
Siyet
previously approved these changes
Oct 18, 2026
sobolevn
approved these changes
Oct 18, 2026
sobolevn
added this pull request to the merge queue
Oct 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Release the owned iterator reference in
Encoder.encode_lineson both success and error paths. The success-pathPy_DECREFstays inside the iterator branch; error cleanup usesPy_XDECREF.Validation on macOS arm64 / CPython 3.14.8: 6,536 unit tests passed (143 skipped). Ruff, formatting, codespell and diff checks passed. The patch also passed 6,554 unit tests against current upstream.
Local sanitizers were not run; hosted sanitizer CI still needs maintainer approval.