Repository navigation
Preserve custom regex matching when selecting native backends - #184
Open
anticipate218 wants to merge 1 commit into
Open
anticipate218 wants to merge 1 commit into
anticipate218 wants to merge 1 commit into
Conversation
Keep custom RegexPattern matching on the simple backend during automatic selection. Reject it through existing explicit native compatibility checks, including instance delegation, while preserving native execution for standard and inactive patterns. Assisted-by: OpenAI Codex
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.
A
RegexPatternsubclass can overridematch_file()to apply additional filtering, but native backend selection only checks its stored regex. With RE2 or Hyperscan installed, the default backend silently bypasses that method. For example, a pattern that selects Python files only outsideprivate/matchesprivate/secret.pyafter installing a native engine, although the simple backend correctly excludes it.Require native-compatible patterns to use the original
RegexPattern.match_filebound to the same object. Automatic selection then preserves overridden, inherited, instance-assigned, or delegated matching through the simple backend. Explicit native selection reports the existing compatibility error. Inactive patterns and subclasses inheriting the original method retain native execution.Seven regression methods cover both spec classes, both real native engines, include/exclude combinations,
+/+=, pattern indices, inactive controls and ordinary subclasses. This is separate from #183, which optimizes the simple backend and does not change native compatibility selection.Validation on Windows / CPython 3.13.5, with google-re2 1.1.20251105 and hyperscan 0.9.1 installed:
python -m unittest discover -t . -s tests/: 329 tests pass with no skips.git diff --checkpass. The final test-only type annotation was added after the distribution build; production files are unchanged.Other Python versions, Linux/macOS and separately created tox backend environments were not run. The documentation build used Sphinx 9.2.0 rather than the pinned 9.1.0 because the pinned dependency installation timed out. No production incident or prevalence is claimed. README and changelog documentation are updated; unrelated existing generated-document drift is left unchanged.
AI assistance: OpenAI Codex investigated the implementation, prepared the patch/tests and draft, and ran validation with independent automated review. No human code review is claimed.