[New-bugs-announce] [issue15846] literal_eval raises SystemError instead of SyntaxError, because of illegal escape sequence

David Halter report at bugs.python.org
Sun Sep 2 10:46:06 CEST 2012

New submission from David Halter:

Hi! I'm the developer of Jedi: https://github.com/davidhalter/jedi, which is an auto-completion library. I try to support Python 2.5-3.2.
The bug just appears in Python 3.2.

Parsing string literals with literal_eval works normally without a problem, but in this certain constellation, it raises a SystemError (instead of a SyntaxError).

The error line is simple:

But: It only raises the error in that particular place:

To try and test it:

git clone git://github.com/davidhalter/jedi.git
cd jedi
# uncomment the line after TODO in parsing.Scope.add_docstr
python3 test/run.py array

The error message:

Traceback (most recent call last):
  File "./run.py", line 51, in run_definition_test
    result = defs(line_nr, len(line))
  File "./run.py", line 49, in defs
    return set(functions.get_definitions(source, line_nr, indent, path))
  File "./functions.py", line 253, in get_definitions
    scopes = _prepare_goto(source, pos, source_path, f, goto_path)
  File "./functions.py", line 227, in _prepare_goto
    scopes = evaluate.follow_statement(stmt)
  File "./helpers.py", line 23, in __call__
    if self.push_stmt(stmt):
  File "./helpers.py", line 31, in push_stmt
    self.current = RecursionNode(stmt, self.current)
  File "./helpers.py", line 75, in __init__
    or (self.script == builtin.Builtin.scope)
  File "./builtin.py", line 408, in scope
    return self._builtins.parser.module
  File "./builtin.py", line 42, in parser
  File "./builtin.py", line 50, in _load_module
    self._parser = parsing.PyFuzzyParser(source, self.path or self.name)
  File "./parsing.py", line 1047, in __init__
  File "./parsing.py", line 1600, in parse
    stmt, tok = self._parse_statement(self.current)
  File "./parsing.py", line 1386, in _parse_statement
  File "./parsing.py", line 157, in add_docstr
  File "/usr/lib/python3.2/ast.py", line 48, in literal_eval
    node_or_string = parse(node_or_string, mode='eval')
  File "/usr/lib/python3.2/ast.py", line 36, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
SystemError: ../Objects/tupleobject.c:126: bad argument to internal function


messages: 169687
nosy: davidhalter
priority: normal
severity: normal
status: open
title: literal_eval raises SystemError instead of SyntaxError, because of illegal escape sequence
versions: Python 3.2

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list