Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Span for invalid escape sequence in multiline strings is wrong #116042

Closed
Labels
3.13bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)
@konstin

Description

@konstin

Bug report

Bug description:

a="""Invalid\ Escape"""

When running withPYTHONWARNINGS=error python3.13 example.py, i get the correct error that there is an invalid escape sequence, but the error span is located at the beginning of the string, not at the location of the actual error:

  File"/home/konsti/example.py", line1    a="""^SyntaxError:invalid escape sequence '\ '

Similarly, for docstrings, the opening quotes are marked, not the actual location:

deff():"""This function computes f.    Invalid\ Escape    """
$ PYTHONWARNINGS=error python3.13 example.py   File"/home/konsti/example.py", line2"""This function computes f.^^^SyntaxError:invalid escape sequence '\ '

This makes it look like the file is somehow corrupted or there is an encoding error rather than checking the actual docstring (astral-sh/uv#1928).

Python 3.13.0a1+, installed with pyenv.

I'd expected this to have been reported before, but searching for "invalid escape sequence strings", "escape sequence span" and "SyntaxWarning location" i didn't find anything matching.

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp