Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyPy version 6.0.0 have different offset in SyntaxError exception #3460

Closed
onovy opened this issue May 10, 2018 · 3 comments
Closed

PyPy version 6.0.0 have different offset in SyntaxError exception #3460

onovy opened this issue May 10, 2018 · 3 comments
Labels
type: infrastructure improvement to development/releases/CI structure

Comments

@onovy
Copy link

onovy commented May 10, 2018

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

@pytestbot
Copy link
Contributor

GitMate.io thinks possibly related issues are #2242 (different behavior for pytest xfail in 2.9.2 version and 3.0.6 ), #3144 (Exit exception), #561 (SyntaxError in docs), and #988 (With py.test raises on python2.6, weird exception instances).

@nicoddemus nicoddemus added the type: infrastructure improvement to development/releases/CI structure label May 10, 2018
@nicoddemus
Copy link
Member

Thanks! We will apply the same patch once we start testing with PyPy 6.0!

FRidh pushed a commit to NixOS/nixpkgs that referenced this issue Jul 3, 2019
@Zac-HD
Copy link
Member

Zac-HD commented Jan 24, 2020

def test_syntaxerror_rerepresentation() -> None:
ex = pytest.raises(SyntaxError, _pytest._code.compile, "xyz xyz")
assert ex is not None
assert ex.value.lineno == 1
assert ex.value.offset in {5, 7} # cpython: 7, pypy3.6 7.1.1: 5
assert ex.value.text == "xyz xyz\n"

@Zac-HD Zac-HD closed this as completed Jan 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: infrastructure improvement to development/releases/CI structure
Projects
None yet
Development

No branches or pull requests

4 participants