Skip to content

mixed bytes and string raises ValueError instead of SyntaxError #4100

Closed

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

Activity

  1. added 7 commits that reference this issue on Aug 22, 2022
    277f80e
    1fd1566
    c39b810
    578c20e
    c9536d1
    ec43789
    55061c7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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