Repository navigation
Handle CSV writer callbacks safely - #9636
Merged
youknowone merged 2 commits intoNov 4, 2026
Merged
Conversation
Assisted-by: OpenAI Codex:model version not exposed
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 41 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Assisted-by: OpenAI Codex:model version not exposed
This was referenced Nov 3, 2026
youknowone
approved these changes
Nov 4, 2026
youknowone
marked this pull request as ready for review
November 4, 2026 01:21
youknowone
enabled auto-merge (squash)
November 4, 2026 01:21
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Summary
Use the existing callback-aware
PyOperationforcsv.writer.writerowinstead of holding a non-reentrant unit mutex across iterator, field conversion, and write callbacks. A callback that invokes the same writer can otherwise wait on its own mutex. The writer's output buffer is local to each call, and its dialect and write target are immutable.Obtain the row iterator through the normal iterator protocol and translate only iterator-acquisition TypeErrors to
_csv.Error, as CPython does. Other acquisition errors and errors raised while advancing the iterator still propagate.The row argument remains owned until after the operation section exits. This change introduces interpreter binding and operation bookkeeping; its runtime cost has not been benchmarked.
Scope
This addresses the lock/reentry behavior, not complete reentrant-output parity. CPython reuses an internal record buffer: a nested
writerowfrom a field's__str__can affect the outer record. RustPython constructs each record locally and already materializes input fields before string conversion, so its reentrant output and callback order can differ. Other iterator handling differences remain outside this change. Type names longer than 200 bytes are truncated at a UTF-8 boundary, which can differ from CPython at a multibyte cutoff.This combines cleanly at file level with #9635; no merge was performed.
Validation
__iter__returns and writes both records. A nested__str__reproduction confirmed the buffer difference described above.__iter__, a non-iterator return, and TypeError from__next__.test_csvcoverage.