Skip to content

Parses crash on invalid use of unicode string literal #588

Closed

Description

@JukkaL

This causes a parser crash (Python 3 mode):

x u''

Here's the stack trace:

Traceback (most recent call last):
  File "scripts/mypy", line 169, in <module>
    main()
  File "scripts/mypy", line 34, in main
    type_check_only(path, module, bin_dir, options)
  File "scripts/mypy", line 78, in type_check_only
    python_path=options.python_path)
  File "/home/jukka/project/mypy/mypy/build.py", line 164, in build
    result = manager.process(UnprocessedFile(info, program_text))
  File "/home/jukka/project/mypy/mypy/build.py", line 342, in process
    next.process()
  File "/home/jukka/project/mypy/mypy/build.py", line 660, in process
    tree = self.parse(self.program_text, self.path)
  File "/home/jukka/project/mypy/mypy/build.py", line 739, in parse
    custom_typing_module=self.manager.custom_typing_module)
  File "/home/jukka/project/mypy/mypy/parse.py", line 80, in parse
    tree = parser.parse(s)
  File "/home/jukka/project/mypy/mypy/parse.py", line 117, in parse
    file = self.parse_file()
  File "/home/jukka/project/mypy/mypy/parse.py", line 125, in parse_file
    defs = self.parse_defs()
  File "/home/jukka/project/mypy/mypy/parse.py", line 250, in parse_defs
    self.expect_break()
  File "/home/jukka/project/mypy/mypy/parse.py", line 1535, in expect_break
    return self.expect_type(Break)
  File "/home/jukka/project/mypy/mypy/parse.py", line 1529, in expect_type
    self.parse_error()
  File "/home/jukka/project/mypy/mypy/parse.py", line 1547, in parse_error
    self.parse_error_at(self.current())
  File "/home/jukka/project/mypy/mypy/parse.py", line 1558, in parse_error_at
    msg = 'Parse error before {}'.format(token_repr(tok))
  File "/home/jukka/project/mypy/mypy/parse.py", line 1674, in token_repr
    raise ValueError('Unknown token {}'.format(repr(tok)))
ValueError: Unknown token UnicodeLit( u'')
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

    bugmypy got something wrong

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions