fix(serializer): Don't call __iter__ on arbitrary sequences#6304
Merged
Conversation
Contributor
Codecov Results 📊✅ 282 passed | Total: 282 | Pass Rate: 100% | Execution Time: 43.06s 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 14891 uncovered lines. Files with missing lines (1)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 33.42% 33.42% —%
==========================================
Files 190 190 —
Lines 22366 22367 +1
Branches 7594 7594 —
==========================================
+ Hits 7475 7476 +1
- Misses 14891 14891 —
- Partials 744 744 —Generated by Codecov Action |
__iter__ arbitrary sequences__iter__ on arbitrary sequences
alexander-alderman-webb
approved these changes
May 20, 2026
Contributor
alexander-alderman-webb
left a comment
There was a problem hiding this comment.
Possibly leads to some data loss but it's worth it to not interfere with users apps IMO.
ericapisani
approved these changes
May 20, 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.
Description
The serializer will attempt to serialize whatever objects are thrown into it. This includes arbitrary local variables in folks' programs that might have all sorts of side-effects.
Notably, if an object is a
Sequence(it has__iter__,__len__, and__getitem__), we will try to__iter__over it. Which is potentially an unwise thing to do, as we know nothing about the object's custom__iter__implementation. It can, for example, acquire a non-reentrant lock. In some scenarios, this can lead to deadlocks caused by the SDK.In this PR, the serializer is changed so that we don't try to
__iter__over allSequences, just built-in stdlib ones. Of course, nothing is preventing folks from defining side-effecty lists, tuples and sets, but it's a bit less likely to happen than on a custom class. Custom sequences will now be simply__repr__'d.Issues
Reminders
tox -e linters.feat:,fix:,ref:,meta:)