Skip to content

Fix invalid escape sequences in tensorrt.plugin docstrings - #4892

Open
KRRT7 wants to merge 1 commit into
NVIDIA:mainfrom
KRRT7:plugin-docstring-escapes
Open

KRRT7 wants to merge 1 commit into
NVIDIA:mainfrom
KRRT7:plugin-docstring-escapes

Conversation

@KRRT7

@KRRT7 KRRT7 commented Oct 24, 2026

Copy link
Copy Markdown

Importing tensorrt.plugin prints nine SyntaxWarning: "\s" is an invalid escape sequence lines on Python 3.12+. Under -W error the import fails outright. The source is the reST plural idiom :class:`X`\s inside regular (non-raw) docstrings in _lib.py, _tensor.py and _top_level.py.

This doubles the backslash (\s → \\s). Python already keeps the backslash for an unrecognized escape, so the docstrings are byte-identical before and after, and the Sphinx output doesn't change.

Checked with CPython 3.15.0:

  • Before: compile(..., -W error) fails with SyntaxError: "\s" is an invalid escape sequence.
  • After: all three files compile cleanly with -W error.
  • All 253 string constants in the three files (via ast) are identical before and after.

Found while building and testing the bindings for Python 3.15 (#4890).

The reST plural trick :class:`X`\s was written as "\s" in regular
(non-raw) docstrings. Python keeps the backslash today but emits a
SyntaxWarning on import, an error under -W error, and has said these
will stop working in a future version. Doubling the backslash produces
byte-identical docstrings, so the rendered docs do not change.

Signed-off-by: Kevin Turcios <turcioskevinr@gmail.com>
@KRRT7
KRRT7 requested a review from a team as a code owner October 24, 2026 09:09
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