Skip to content

PyPy version 6.0.0 have different offset in SyntaxError exception #3460

@onovy

Description

@onovy

PyPy version 6.0.0 have different offset in SyntaxError exception, see:

$ pypy
Python 2.7.13 (6.0.0+dfsg-1, Apr 27 2018, 22:07:01)
[PyPy 6.0.0 with GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>> try:
....     eval('xyz xyz')
.... except SyntaxError as e:
....     print(e.offset)
....
5

This breaks tests: testing/code/test_source.py::test_syntaxerror_rerepresentation

with error:

> ______________________ test_syntaxerror_rerepresentation _______________________
> 
>     def test_syntaxerror_rerepresentation():
>         ex = pytest.raises(SyntaxError, _pytest._code.compile, 'xyz xyz')
>         assert ex.value.lineno == 1
> >       assert ex.value.offset in (4, 7)  # XXX pypy/jython versus cpython?
> E       AssertionError: assert 5 in (4, 7)
> E        +  where 5 = SyntaxError('xyz xyz\n     ^\n(code was compiled probably from here: <69-codeg...C7rT/pytest-3.3.2/.pybuild/pypy_6.0_pytest/build/_pytest/python_api.py:589>)',).offset
> E        +    where SyntaxError('xyz xyz\n     ^\n(code was compiled probably from here: <69-codeg...C7rT/pytest-3.3.2/.pybuild/pypy_6.0_pytest/build/_pytest/python_api.py:589>)',) = <ExceptionInfo SyntaxError tblen=3>.value
> 
> ../../../testing/code/test_source.py:120: AssertionError

Fixed in Debian: bug commit

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: infrastructureimprovement to development/releases/CI structure

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions