tests(py): don't draw lone surrogates into a pyarrow string column - #103
Merged
Conversation
`test_roundtrip_arbitrary_primitive_tables` failed at random with
UnicodeEncodeError: 'utf-8' codec can't encode character '\ud800'
while generating 'table' from _mixed_tables()
`st.text()` draws from all of Unicode including the surrogate range, and a lone
`\ud800` is a valid Python `str` with no UTF-8 encoding — so `pa.array` raised
while *building* the example, before pgpq saw anything. Excluding category `Cs`
alongside the `\x00` that was already excluded fixes it.
Found while cutting 0.12.0: this reproduces on plain `main`, and would show up in
CI as an occasional unexplained failure. Ran 8 random hypothesis seeds after the
fix, all green.
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.
test_roundtrip_arbitrary_primitive_tablesfails at random onmain:st.text()draws from all of Unicode including the surrogate range. A lone\ud800is aperfectly valid Python
strbut has no UTF-8 encoding, sopa.arrayraises while buildingthe example — the failure happens in the generator, before pgpq is involved at all, which is
why the traceback has nothing to do with encoding.
The strategy already excluded
\x00(Postgres rejects it intext); this adds the surrogatecategory
Csnext to it, with the reasoning recorded inline.Found while cutting 0.12.0 — it reproduces on plain
main, so it has been an occasionalunexplained CI failure waiting to happen. Verified with 8 random hypothesis seeds after the fix,
all green, plus the full Python suite (25 passed) against a real Postgres.