Page MenuHomeVyOS Platform

Resolve regex escape sequences
In progress, NormalPublicFEATURE REQUEST

Description

With Python 3.13 in Trixie, invalid escape sequences in strings raise a printed warning for each occurrence.

Example:

DEBUG - /usr/libexec/vyos/tests/smoke/cli/base_accel_ppp_test.py:253: SyntaxWarning: invalid escape sequence '\s'
DEBUG -   regex = f"{user}\s+\*\s+{password}\s+{static_ip}\s+{download}/{upload}"
DEBUG - /usr/libexec/vyos/tests/smoke/cli/base_accel_ppp_test.py:253: SyntaxWarning: invalid escape sequence '\s'
DEBUG -   regex = f"{user}\s+\*\s+{password}\s+{static_ip}\s+{download}/{upload}"
DEBUG - /usr/libexec/vyos/tests/smoke/cli/base_accel_ppp_test.py:253: SyntaxWarning: invalid escape sequence '\s'
DEBUG -   regex = f"{user}\s+\*\s+{password}\s+{static_ip}\s+{download}/{upload}"
DEBUG - /usr/libexec/vyos/tests/smoke/cli/base_accel_ppp_test.py:266: SyntaxWarning: invalid escape sequence '\s'
DEBUG -   regex = f"{user}\s+\*\s+{password}\s+\*\s+{download}/{upload}"
DEBUG - /usr/libexec/vyos/tests/smoke/cli/base_accel_ppp_test.py:266: SyntaxWarning: invalid escape sequence '\s'
DEBUG -   regex = f"{user}\s+\*\s+{password}\s+\*\s+{download}/{upload}"

Details

Version
-
Is it a breaking change?
Perfectly compatible
Issue type
Bug (incorrect behavior)

Related Objects

StatusSubtypeAssignedTask
In progressFEATURE REQUESTsarthurdev
In progressFEATURE REQUESTsarthurdev

Event Timeline

sarthurdev changed the task status from Open to In progress.
sarthurdev triaged this task as Normal priority.
sarthurdev created this object with edit policy "Custom Policy".

Hi, is this still in progress? I have a branch that fixes the invalid escape sequences currently in rolling, and I don't want to duplicate your work.

It changes 21 string literals in 15 files (library, conf-mode, op-mode scripts and smoketests). Literals with only invalid escapes become raw strings. Where a literal also has a real escape such as \n, the invalid backslash is doubled instead. The compiled constants are unchanged: the AST of each file is identical before and after. On a trixie container (Python 3.13), python3 -W error -m compileall python src smoketest fails on 15 files on rolling and passes with the branch.

If it helps, I can open a PR against this task, split into library/scripts and smoketests if you prefer. If you already have a fix in progress, I'll drop mine.

@rasty94 This task will be merged as part of the pending Trixie update where Python 3.13 is more vocal about these issues.