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

Test failures with Python 3.13.0b1 #56

Open
hroncok opened this issue May 16, 2024 · 2 comments
Open

Test failures with Python 3.13.0b1 #56

hroncok opened this issue May 16, 2024 · 2 comments

Comments

@hroncok
Copy link
Contributor

hroncok commented May 16, 2024

Hello,

in Fedora, we are trying to rebuild everything with Python 3.13.

stack_data currently fails tests. It can be reproduced from your repository by running tox -e py313:

.pkg: _optional_hooks> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta
.pkg: get_requires_for_build_sdist> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta
.pkg: get_requires_for_build_wheel> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta
.pkg: prepare_metadata_for_build_wheel> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta
.pkg: build_sdist> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta
py313: install_package> python -I -m pip install --force-reinstall --no-deps .../stack_data/.tox/.tmp/package/2/stack_data-0.6.3.tar.gz
py313: commands[0]> pytest
============================= test session starts ==============================
platform linux -- Python 3.13.0b1, pytest-8.2.0, pluggy-1.5.0
cachedir: .tox/py313/.pytest_cache
rootdir: .../stack_data
configfile: pyproject.toml
plugins: typeguard-4.2.1
collected 21 items

tests/test_core.py ...F.F.......FF                                       [ 71%]
tests/test_formatter.py F.                                               [ 80%]
tests/test_serializer.py F                                               [ 85%]
tests/test_utils.py ...                                                  [100%]

=================================== FAILURES ===================================
________________________________ test_variables ________________________________

    def test_variables():
        options = Options(before=1, after=0)
        assert repr(options) == ('Options(after=0, before=1, ' +
                                 'blank_lines=<BlankLines.HIDDEN: 1>,' +
                                 ' include_signature=False, ' +
                                 'max_lines_per_piece=6, pygments_formatter=None)')
    
        def foo(arg, _arg2: str = None, *_args, **_kwargs):
            y = 123986
            str(y)
            x = {982347298304}
            str(x)
            return (
                FrameInfo(inspect.currentframe(), options),
                arg,
                arg,
            )[0]
    
        frame_info = foo('this is arg')
    
        assert sum(line.is_current for line in frame_info.lines) == 1
    
        body = frame_info.scope.body
    
        tup = body[-1].value.value.elts
        call = tup[0]
>       assert frame_info.executing.node == call
E       AssertionError: assert None == <ast.Call object at 0x7fe1780e0ed0>
E        +  where None = <executing.executing.Executing object at 0x7fe17819b020>.node
E        +    where <executing.executing.Executing object at 0x7fe17819b020> = FrameInfo(<frame at 0x7fe177df8220, file '.../stack_data/tests/test_core.py', line 219, code foo>).executing

tests/test_core.py:233: AssertionError
_____________________________ test_skipping_frames _____________________________

collapse = True

    def check_skipping_frames(collapse: bool):
        def factorial(n):
            if n <= 1:
                return 1 / 0  # exception lineno
            return n * foo(n - 1)  # factorial lineno
    
        def foo(n):
            return factorial(n)  # foo lineno
    
        try:
>           factorial(20)  # check_skipping_frames lineno

tests/test_core.py:430: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_core.py:424: in factorial
    return n * foo(n - 1)  # factorial lineno
tests/test_core.py:427: in foo
    return factorial(n)  # foo lineno
tests/test_core.py:424: in factorial
    return n * foo(n - 1)  # factorial lineno
tests/test_core.py:427: in foo
    return factorial(n)  # foo lineno
tests/test_core.py:424: in factorial
    return n * foo(n - 1)  # factorial lineno
tests/test_core.py:427: in foo
    return factorial(n)  # foo lineno
tests/test_core.py:424: in factorial
    return n * foo(n - 1)  # factorial lineno
tests/test_core.py:427: in foo
    return factorial(n)  # foo lineno
tests/test_core.py:424: in factorial
    return n * foo(n - 1)  # factorial lineno
tests/test_core.py:427: in foo
    return factorial(n)  # foo lineno
tests/test_core.py:424: in factorial
    return n * foo(n - 1)  # factorial lineno
tests/test_core.py:427: in foo
    return factorial(n)  # foo lineno
tests/test_core.py:424: in factorial
    return n * foo(n - 1)  # factorial lineno
tests/test_core.py:427: in foo
    return factorial(n)  # foo lineno
tests/test_core.py:424: in factorial
    return n * foo(n - 1)  # factorial lineno
tests/test_core.py:427: in foo
    return factorial(n)  # foo lineno
tests/test_core.py:424: in factorial
    return n * foo(n - 1)  # factorial lineno
tests/test_core.py:427: in foo
    return factorial(n)  # foo lineno
tests/test_core.py:424: in factorial
    return n * foo(n - 1)  # factorial lineno
tests/test_core.py:427: in foo
    return factorial(n)  # foo lineno
tests/test_core.py:424: in factorial
    return n * foo(n - 1)  # factorial lineno
tests/test_core.py:427: in foo
    return factorial(n)  # foo lineno
tests/test_core.py:424: in factorial
    return n * foo(n - 1)  # factorial lineno
tests/test_core.py:427: in foo
    return factorial(n)  # foo lineno
tests/test_core.py:424: in factorial
    return n * foo(n - 1)  # factorial lineno
tests/test_core.py:427: in foo
    return factorial(n)  # foo lineno
tests/test_core.py:424: in factorial
    return n * foo(n - 1)  # factorial lineno
tests/test_core.py:427: in foo
    return factorial(n)  # foo lineno
tests/test_core.py:424: in factorial
    return n * foo(n - 1)  # factorial lineno
tests/test_core.py:427: in foo
    return factorial(n)  # foo lineno
tests/test_core.py:424: in factorial
    return n * foo(n - 1)  # factorial lineno
tests/test_core.py:427: in foo
    return factorial(n)  # foo lineno
tests/test_core.py:424: in factorial
    return n * foo(n - 1)  # factorial lineno
tests/test_core.py:427: in foo
    return factorial(n)  # foo lineno
tests/test_core.py:424: in factorial
    return n * foo(n - 1)  # factorial lineno
tests/test_core.py:427: in foo
    return factorial(n)  # foo lineno
tests/test_core.py:424: in factorial
    return n * foo(n - 1)  # factorial lineno
tests/test_core.py:427: in foo
    return factorial(n)  # foo lineno
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

n = 1

    def factorial(n):
        if n <= 1:
>           return 1 / 0  # exception lineno
E           ZeroDivisionError: division by zero

tests/test_core.py:423: ZeroDivisionError

During handling of the above exception, another exception occurred:

    def test_skipping_frames():
>       check_skipping_frames(True)

tests/test_core.py:479: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_core.py:435: in check_skipping_frames
    for x in FrameInfo.stack_data(tb, collapse_repeated_frames=collapse):
stack_data/core.py:597: in stack_data
    yield from collapse_repeated(
stack_data/utils.py:83: in collapse_repeated
    yield from map(mapper, original_group)
stack_data/core.py:587: in mapper
    return cls(f, options)
stack_data/core.py:551: in __init__
    self.executing = Source.executing(frame_or_tb)
.tox/py313/lib/python3.13/site-packages/executing/executing.py:283: in executing
    assert_(new_stmts <= stmts)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

condition = False, message = ''

    def assert_(condition, message=""):
        # type: (Any, str) -> None
        """
        Like an assert statement, but unaffected by -O
        :param condition: value that is expected to be truthy
        :type message: Any
        """
        if not condition:
>           raise AssertionError(str(message))
E           AssertionError

.tox/py313/lib/python3.13/site-packages/executing/executing.py:80: AssertionError
_________________________________ test_example _________________________________

    def test_example():
        from .samples.example import bar
>       result = bar()

tests/test_core.py:590: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/samples/example.py:27: in bar
    exec("result = foo()", globals(), names)
<string>:1: in <module>
    ???
tests/samples/example.py:20: in foo
    result = print_stack(
tests/samples/example.py:35: in print_stack
    for frame_info in list(FrameInfo.stack_data(frame, options))[-3:]:
stack_data/core.py:597: in stack_data
    yield from collapse_repeated(
stack_data/utils.py:83: in collapse_repeated
    yield from map(mapper, original_group)
stack_data/core.py:587: in mapper
    return cls(f, options)
stack_data/core.py:551: in __init__
    self.executing = Source.executing(frame_or_tb)
.tox/py313/lib/python3.13/site-packages/executing/executing.py:283: in executing
    assert_(new_stmts <= stmts)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

condition = False, message = ''

    def assert_(condition, message=""):
        # type: (Any, str) -> None
        """
        Like an assert statement, but unaffected by -O
        :param condition: value that is expected to be truthy
        :type message: Any
        """
        if not condition:
>           raise AssertionError(str(message))
E           AssertionError

.tox/py313/lib/python3.13/site-packages/executing/executing.py:80: AssertionError
____________________________ test_pygments_example _____________________________

    @pytest.mark.skipif(pygments_version < (2, 14), reason="Different output in older Pygments")
    def test_pygments_example():
        from .samples.pygments_example import bar
>       result = bar()

tests/test_core.py:636: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/samples/pygments_example.py:17: in bar
    @deco
tests/samples/pygments_example.py:26: in deco
    f.result = print_stack()
tests/samples/pygments_example.py:43: in print_stack
    for frame_info in list(FrameInfo.stack_data(frame, options))[-2:]:
stack_data/core.py:597: in stack_data
    yield from collapse_repeated(
stack_data/utils.py:83: in collapse_repeated
    yield from map(mapper, original_group)
stack_data/core.py:587: in mapper
    return cls(f, options)
stack_data/core.py:551: in __init__
    self.executing = Source.executing(frame_or_tb)
.tox/py313/lib/python3.13/site-packages/executing/executing.py:283: in executing
    assert_(new_stmts <= stmts)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

condition = False, message = ''

    def assert_(condition, message=""):
        # type: (Any, str) -> None
        """
        Like an assert statement, but unaffected by -O
        :param condition: value that is expected to be truthy
        :type message: Any
        """
        if not condition:
>           raise AssertionError(str(message))
E           AssertionError

.tox/py313/lib/python3.13/site-packages/executing/executing.py:80: AssertionError
_________________________________ test_example _________________________________

n = 0

    def foo(n=5):
        if n > 0:
            return foo(n - 1)
        x = 1
        lst = (
                [
                    x,
                ]
                + []
                + []
                + []
                + []
                + []
        )
        try:
>           return int(str(lst))
E           ValueError: invalid literal for int() with base 10: '[1]'

tests/samples/formatter_example.py:21: ValueError

During handling of the above exception, another exception occurred:

n = 0

    def foo(n=5):
        if n > 0:
            return foo(n - 1)
        x = 1
        lst = (
                [
                    x,
                ]
                + []
                + []
                + []
                + []
                + []
        )
        try:
            return int(str(lst))
        except:
            try:
>               return 1 / 0
E               ZeroDivisionError: division by zero

tests/samples/formatter_example.py:24: ZeroDivisionError

The above exception was the direct cause of the following exception:

capsys = <_pytest.capture.CaptureFixture object at 0x7fe17805ecf0>

    def test_example(capsys):
        from .samples.formatter_example import bar, print_stack1, format_stack1, format_frame, f_string, blank_lines
    
        @contextmanager
        def check_example(name):
            yield
            stderr = capsys.readouterr().err
            compare_to_file(stderr, name)
    
        with check_example("variables"):
            try:
>               bar()

tests/test_formatter.py:44: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/samples/formatter_example.py:30: in bar
    exec("foo()")
<string>:1: in <module>
    ???
tests/samples/formatter_example.py:8: in foo
    return foo(n - 1)
tests/samples/formatter_example.py:8: in foo
    return foo(n - 1)
tests/samples/formatter_example.py:8: in foo
    return foo(n - 1)
tests/samples/formatter_example.py:8: in foo
    return foo(n - 1)
tests/samples/formatter_example.py:8: in foo
    return foo(n - 1)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

n = 0

    def foo(n=5):
        if n > 0:
            return foo(n - 1)
        x = 1
        lst = (
                [
                    x,
                ]
                + []
                + []
                + []
                + []
                + []
        )
        try:
            return int(str(lst))
        except:
            try:
                return 1 / 0
            except Exception as e:
>               raise TypeError from e
E               TypeError

tests/samples/formatter_example.py:26: TypeError

During handling of the above exception, another exception occurred:

capsys = <_pytest.capture.CaptureFixture object at 0x7fe17805ecf0>

    def test_example(capsys):
        from .samples.formatter_example import bar, print_stack1, format_stack1, format_frame, f_string, blank_lines
    
        @contextmanager
        def check_example(name):
            yield
            stderr = capsys.readouterr().err
            compare_to_file(stderr, name)
    
        with check_example("variables"):
            try:
                bar()
            except Exception:
>               MyFormatter(show_variables=True).print_exception()

tests/test_formatter.py:46: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
stack_data/formatting.py:84: in print_exception
    self.print_lines(self.format_exception(e), file=file)
stack_data/formatting.py:95: in print_lines
    for line in lines:
stack_data/formatting.py:112: in format_exception
    yield from self.format_stack(e.__traceback__)
stack_data/formatting.py:119: in format_stack
    yield from self.format_stack_data(
stack_data/formatting.py:130: in format_stack_data
    for item in stack:
stack_data/core.py:597: in stack_data
    yield from collapse_repeated(
stack_data/utils.py:83: in collapse_repeated
    yield from map(mapper, original_group)
stack_data/core.py:587: in mapper
    return cls(f, options)
stack_data/core.py:551: in __init__
    self.executing = Source.executing(frame_or_tb)
.tox/py313/lib/python3.13/site-packages/executing/executing.py:283: in executing
    assert_(new_stmts <= stmts)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

condition = False, message = ''

    def assert_(condition, message=""):
        # type: (Any, str) -> None
        """
        Like an assert statement, but unaffected by -O
        :param condition: value that is expected to be truthy
        :type message: Any
        """
        if not condition:
>           raise AssertionError(str(message))
E           AssertionError

.tox/py313/lib/python3.13/site-packages/executing/executing.py:80: AssertionError
----------------------------- Captured stderr call -----------------------------
Traceback (most recent call last):
 File "formatter_example.py", line 21, in foo
       9 | x = 1
      10 | lst = (
      11 |         [
      12 |             x,
(...)
      18 |         + []
      19 | )
      20 | try:
-->   21 |     return int(str(lst))
      22 | except:
[
                x,
            ] = [1]
[
                x,
            ]
            + [] = [1]
[
                x,
            ]
            + []
            + [] = [1]
[
                x,
            ]
            + []
            + []
            + [] = [1]
[
                x,
            ]
            + []
            + []
            + []
            + [] = [1]
[
                x,
            ]
            + []
            + []
            + []
            + []
            + [] = [1]
lst = [1]
n = 0
n - 1 = -1
n > 0 = False
str(lst) = '[1]'
x = 1
ValueError: invalid literal for int() with base 10: '[1]'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
 File "formatter_example.py", line 24, in foo
      21 |     return int(str(lst))
      22 | except:
      23 |     try:
-->   24 |         return 1 / 0
      25 |     except Exception as e:
[
                x,
            ] = [1]
[
                x,
            ]
            + [] = [1]
[
                x,
            ]
            + []
            + [] = [1]
[
                x,
            ]
            + []
            + []
            + [] = [1]
[
                x,
            ]
            + []
            + []
            + []
            + [] = [1]
[
                x,
            ]
            + []
            + []
            + []
            + []
            + [] = [1]
lst = [1]
n = 0
n - 1 = -1
n > 0 = False
str(lst) = '[1]'
x = 1
ZeroDivisionError: division by zero

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
_________________________________ test_example _________________________________

    def test_example():
        from .samples.formatter_example import bar, format_frame, format_stack1
    
        result = dict(
            format_frame=(format_frame(MyFormatter())),
>           format_stack=format_stack1(MyFormatter(show_variables=True)),
        )

tests/test_serializer.py:29: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/samples/formatter_example.py:42: in format_stack1
    return format_stack2(formatter)
tests/samples/formatter_example.py:46: in format_stack2
    return list(formatter.format_stack())
stack_data/serializing.py:105: in format_stack
    return list(
stack_data/serializing.py:118: in format_stack_data
    for item in stack:
stack_data/core.py:597: in stack_data
    yield from collapse_repeated(
stack_data/utils.py:83: in collapse_repeated
    yield from map(mapper, original_group)
stack_data/core.py:587: in mapper
    return cls(f, options)
stack_data/core.py:551: in __init__
    self.executing = Source.executing(frame_or_tb)
.tox/py313/lib/python3.13/site-packages/executing/executing.py:283: in executing
    assert_(new_stmts <= stmts)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

condition = False, message = ''

    def assert_(condition, message=""):
        # type: (Any, str) -> None
        """
        Like an assert statement, but unaffected by -O
        :param condition: value that is expected to be truthy
        :type message: Any
        """
        if not condition:
>           raise AssertionError(str(message))
E           AssertionError

.tox/py313/lib/python3.13/site-packages/executing/executing.py:80: AssertionError
=========================== short test summary info ============================
FAILED tests/test_core.py::test_variables - AssertionError: assert None == <a...
FAILED tests/test_core.py::test_skipping_frames - AssertionError
FAILED tests/test_core.py::test_example - AssertionError
FAILED tests/test_core.py::test_pygments_example - AssertionError
FAILED tests/test_formatter.py::test_example - AssertionError
FAILED tests/test_serializer.py::test_example - AssertionError
========================= 6 failed, 15 passed in 1.55s =========================
py313: exit 1 (1.90 seconds) .../stack_data> pytest pid=2320962
  py313: FAIL code 1 (7.76=setup[5.87]+cmd[1.90] seconds)
  evaluation failed :( (7.83 seconds)
@frenzymadness
Copy link
Contributor

I see that @alexmojaki already opened as issue for executing: alexmojaki/executing#79

@frenzymadness
Copy link
Contributor

There is some work already done in executing in this branch: alexmojaki/executing@master...3.13 but it still doesn't make all tests in executing pass with 3.13 beta 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants