Skip to content

PEP 750: align remaining t-string diagnostics with CPython #8495

Description

@youknowone

Feature

Core template strings work, but several PEP 750 diagnostics still differ from CPython 3.14.

Minimal reproduction:

cases = [
    ("add", lambda: t"a" + "b"),
    ("bytes-mix", lambda: compile('t"x" b"y"', "<test>", "eval")),
]

for name, func in cases:
    try:
        func()
    except Exception as exc:
        print(name, type(exc).__name__, str(exc))

CPython 3.14.6:

add TypeError can only concatenate string.templatelib.Template (not "str") to string.templatelib.Template
bytes-mix SyntaxError cannot mix t-string literals with string or bytes literals (<test>, line 1)

RustPython:

add TypeError can only concatenate Template (not 'str') to Template
bytes-mix SyntaxError cannot mix bytes and nonbytes literals (<test>, line 1)

Related CPython-compatible t-string diagnostics are currently covered by expectedFailure markers in Lib/test/test_tstring.py, including test_template_concatenation, test_syntax_errors, and test_literal_concatenation.

Python Documentation or reference to CPython source code

Metadata

Metadata

Assignees

Labels

C-compatA discrepancy between RustPython and CPython

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions