Skip to content

mixed bytes and string raises ValueError instead of SyntaxError #4100

Closed
@youknowone

Description

@youknowone

Feature

expected:

>>> ast.parse("u'a' b'b'")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/user/.pyenv/versions/3.10.1/lib/python3.10/ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
  File "<unknown>", line 1
    u'a' b'b'
             ^
SyntaxError: cannot mix bytes and nonbytes literals

actual:

>>>>> ast.parse("b'a' 'b'")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/user/Projects/RustPython/vm/pylib-crate/Lib/ast.py", line 50, in parse
    return compile(source, filename, mode, flags)
ValueError: invalid syntax. Got unexpected token "b" at line 1 column 7

probably because RustPython handles it from lexer while CPython handles it from parser

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions