Skip to content

Preserve foreign compiled regex options when selecting a backend - #175

Draft
liuyinchu wants to merge 4 commits into
cpburnz:masterfrom
liuyinchu:patch-1
Draft

liuyinchu wants to merge 4 commits into
cpburnz:masterfrom
liuyinchu:patch-1

Conversation

@liuyinchu

Copy link
Copy Markdown

A precompiled google-re2 expression with Options.case_sensitive = False matches SECRET with the simple backend, but selecting an accelerated backend recompiles only its pattern text and loses that option. The default best selection can therefore change inclusion/exclusion results merely when an optional backend is installed.

Return unsupported from the existing foreign-expression guard, as its comment already intends. Automatic selection then retains the original compiled object with the simple backend; explicit native selection returns the existing guidance to use backend='simple'. Native Python patterns retain their existing path, and inactive foreign patterns do not force fallback.

Adds proxy and real-RE2 regressions, inactive-pattern/index controls, and synchronized documentation. Ten failing baseline subcases become passing; the full Python 3.12 suite runs 298 tests successfully with one existing skip and both native backends installed. Another 84 option/order/exclusion cases pass in independent review. Mypy and Pyright findings are byte-identical on baseline and patch; other Python/OS combinations were not run.

This covers foreign compiled objects, distinct from the stdlib flag preservation in #151.

AI-assisted investigation, implementation, tests and writing; independently reviewed. No production incident is claimed.

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.

1 participant