Skip to content

Fix regular expression syntax warning#670

Open
patrickmacarthur wants to merge 1 commit into
sonic-net:masterfrom
patrickmacarthur:master-fix-regular-expression-syntax-wa
Open

Fix regular expression syntax warning#670
patrickmacarthur wants to merge 1 commit into
sonic-net:masterfrom
patrickmacarthur:master-fix-regular-expression-syntax-wa

Conversation

@patrickmacarthur
Copy link
Copy Markdown

Description

Change regular expressions from regular strings to raw strings.

Motivation and Context

This change eliminates warnings in the logs from Python trying to interpret regular expression escape codes as string escape codes:

2026-05-19T05:32:46.808693+00:00 sonic determine-reboot-cause[1812]: /usr/local/lib/python3.13/dist-packages/sonic_platform_base/sonic_pcie/pcie_common.py:40: SyntaxWarning: invalid escape sequence '\\\\w'\\n
2026-05-19T05:32:46.808782+00:00 sonic determine-reboot-cause[1812]:   p1 = "^(\\\\w+):(\\\\w+)\\\\.(\\\\w)\\\\s(.*)\\\\s*\\\\(*.*\\\\)*"\\n
2026-05-19T05:32:46.808825+00:00 sonic determine-reboot-cause[1812]: /usr/local/lib/python3.13/dist-packages/sonic_platform_base/sonic_pcie/pcie_common.py:41: SyntaxWarning: invalid escape sequence '\\\\w'\\n
2026-05-19T05:32:46.808863+00:00 sonic determine-reboot-cause[1812]:   p2 = "^.*:.*:.*:(\\\\w+)\\\\s*\\\\(*.*\\\\)*"\\n

How Has This Been Tested?

Verified that SONiC and all docker containers can successfully boot with the changes applied, and the SyntaxWarnings do not appear in syslog.

Additional Information (Optional)

Regular expressions in Python should be raw strings so that Python
itself does not interpret the escape sequences as normal string
escape sequences.

Signed-off-by: Patrick MacArthur <pmacarthur@arista.com>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

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.

2 participants