Repository navigation
Support bytes in pure Python edit script application - #508
Open
parijat1222q wants to merge 1 commit into
Open
parijat1222q wants to merge 1 commit into
parijat1222q wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Fixes #507.
Match the native
Editops.apply/Opcodes.applyinput contract in the pure-Python implementation: acceptstrandbytes, reject other types consistently, and convert bytes one-to-one to Unicode codepoints before applying edits. Latin-1 preserves native byte values, including NUL and 0xff; UTF-8 would not preserve the native semantics.The change is limited to the two Python apply methods (16 source lines), plus tests. Existing text inputs retain their behavior. No algorithm, native source, API, or output-type change is proposed.
Added 80 parametrized regression/control cases across both implementations, covering ASCII, non-ASCII and mixed operands, insertion/deletion/replacement/no-op/empty inputs, invalid types, all 256 byte values, and Hypothesis-generated byte strings. Against unchanged main
1d7d2f071c30f376bf47b76e06815f870ac420f8, 36 new Python cases fail and 44 native/control cases pass. All pass with the patch.Validation on Linux:
.hypothesisdirectory.git diff --check: passed.Native modules used for the full suite were built from the same current source/submodules with Debug settings and LTO disabled. The initial optimized build exceeded local compiler memory, so no optimized-build/performance claim is made. Other operating systems, other full interpreter suites, docs builds and the entire pre-commit matrix were not run.
Found through source inspection and local reproduction, not a claimed production incident.