Skip to content

Fix SyntaxWarning for invalid escape sequence in tornado/util.py#68701

Open
AhmadYasser1 wants to merge 2 commits intosaltstack:3006.xfrom
AhmadYasser1:fix/68568/3006.x
Open

Fix SyntaxWarning for invalid escape sequence in tornado/util.py#68701
AhmadYasser1 wants to merge 2 commits intosaltstack:3006.xfrom
AhmadYasser1:fix/68568/3006.x

Conversation

@AhmadYasser1
Copy link
Contributor

@AhmadYasser1 AhmadYasser1 commented Feb 9, 2026

What does this PR do?

Fixes a SyntaxWarning: invalid escape sequence '\d' emitted by Python 3.12+ when importing salt/ext/tornado/util.py.

The re_unescape function's docstring contained a bare \d (as part of documenting that strings containing \d cannot be unescaped). Python 3.12+ treats unrecognized backslash sequences in regular strings as SyntaxWarning, which will become a SyntaxError in a future Python version.

The fix converts the docstring to a raw string (r"""..."""), which preserves the content while preventing the warning.

What issues does this PR fix or reference?

Fixes #68568

Previous Behavior

On Python 3.12+, importing salt.ext.tornado.util produces:

salt/ext/tornado/util.py:246: SyntaxWarning: invalid escape sequence '\d'

New Behavior

No warning is emitted on any Python version.

Merge requirements satisfied?

  • Docs
  • Changelog
  • Tests written/updated

Commits signed with GPG?

No

@AhmadYasser1
Copy link
Contributor Author

The Lint / Lint Salt's Source Code check is failing due to a CI infrastructure issue: cassandra-driver==3.23.0 fails to install because of a pkg_resources / setuptools incompatibility in the 3006.x lint environment. This is unrelated to the one-line docstring change in this PR.

The Pre-Commit check passes, confirming the code change itself is valid.

error: subprocess-exited-with-error
cassandra-driver-3.23.0/ez_setup.py: ModuleNotFoundError: No module named 'pkg_resources'
Session lint-salt failed.

The `re_unescape` function's docstring contained a bare `\d` which
Python 3.12+ treats as an invalid escape sequence, producing:

  SyntaxWarning: invalid escape sequence '\d'

Convert the docstring to a raw string (r"""...""") to prevent the
warning while preserving the docstring content.

Fixes saltstack#68568
The previous lint check failed due to a transient cassandra-driver
install issue unrelated to this change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants