Skip to content

Support bytes in pure Python edit script application - #508

Open
parijat1222q wants to merge 1 commit into
rapidfuzz:mainfrom
parijat1222q:fix-python-apply-bytes
Open

parijat1222q wants to merge 1 commit into
rapidfuzz:mainfrom
parijat1222q:fix-python-apply-bytes

Conversation

@parijat1222q

Copy link
Copy Markdown

Fixes #507.

Match the native Editops.apply / Opcodes.apply input contract in the pure-Python implementation: accept str and bytes, 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:

  • Current-source CPython 3.12.15 full pytest suite: 559 passed, no skips, with pandas installed. One existing Hypothesis collection warning about the ignored .hypothesis directory.
  • Complete initialization test module: 114 passed.
  • Pure-source byte/mixed-input smoke: 1,536 checks each on CPython 3.11.17, 3.12.15 and 3.15.0. These are smoke checks, not full suites on 3.11/3.15.
  • Black 25.1.0 check: passed on changed files.
  • Ruff 0.11.0 check: passed on changed files.
  • 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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pure Python Editops.apply and Opcodes.apply reject documented bytes inputs

1 participant