fix(python): preserve escaped quotes in regex literals
AN
1d ago+105+105+012345678901234567890123456789-2-2-0123456789
Description
Fixes #25490
Preserve an existing backslash before a double quote when preparing Python regex literals. Adding another backslash made the generated raw string syntactically invalid. Unescaped quotes continue to be escaped.
Tests
- Three focused
PythonClientCodegenTesttests passed, including the new regression. - The minimal generated model passes
py_compile; its regex value matches the spec and accepts/rejects the expected characters. - The full generated Python SDK passes
compilealland import. git diff upstream/master...HEAD --checkpassed.
Summary by cubic
Fixes Python regex literal escaping so double quotes preceded by an odd number of backslashes are no longer double-escaped, keeping generated raw strings syntactically valid. Previously any existing backslash before a quote got another backslash, which broke the regex.
Testing
- Added a regression test plus a data-driven test covering quote and backslash combinations (odd/even backslashes and trailing backslashes).
- Verified the generated model compiles and its regex values match the spec.