Skip to content

test_pyexpat: test_exception() fails on Ubuntu and macOS jobs on GitHub Actions #109230

Closed

Description

@vstinner
FAIL: test_exception (test.test_pyexpat.HandlerExceptionTest.test_exception)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_pyexpat.py", line 452, in test_exception
    parser.Parse(b"<a><b><c/></b></a>", True)
  File "../cpython-ro-srcdir/Modules/pyexpat.c", line 421, in StartElement
  File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_pyexpat.py", line 442, in StartElementHandler
    raise RuntimeError(name)
RuntimeError: a

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_pyexpat.py", line 472, in test_exception
    self.assertIn('call_with_frame("StartElement"', entries[1][3])
AssertionError: 'call_with_frame("StartElement"' not found in ''

Comparison of Ubuntu logs:

Linked PRs

Activity

  1. changed the title [-]test_pyexpat: [/-] [+]test_pyexpat: test_exception() fails on Ubuntu and macOS jobs on GitHub Actions[/+] on Sep 10, 2023
  2. added
    type-bugAn unexpected behavior, bug, or error
    testsTests in the Lib/test dir
    on Sep 10, 2023
  3. vstinner commented on Sep 10, 2023

    @vstinner
    MemberAuthor

    Oh wait. Maybe it's a real bug in my PR #109229.

  4. vstinner commented on Sep 10, 2023

    @vstinner
    MemberAuthor

    Oh. This test depends on the current working directory!

    If it's run from the source directory, it pass.

    $ pwd
    /home/vstinner/python/main
    
    $ ls Modules/pyexpat.c
    Modules/pyexpat.c
    
    vstinner@mona$ ./python -m test -v test_pyexpat -m test_exception  -q
    (...)
    Result: SUCCESS
    

    If it's run from a different directory, it fails!

    $ cd ..
    
    $ pwd
    /home/vstinner/python
    
    $ ls Modules/pyexpat.c
    ls: cannot access 'Modules/pyexpat.c': No such file or directory
    
    $ main/python -m test -v test_pyexpat -m test_exception  -q
    (...)
    test test_pyexpat failed -- Traceback (most recent call last):
      File "/home/vstinner/python/main/Lib/test/test_pyexpat.py", line 452, in test_exception
        parser.Parse(b"<a><b><c/></b></a>", True)
      File "./Modules/pyexpat.c", line 421, in StartElement
      File "/home/vstinner/python/main/Lib/test/test_pyexpat.py", line 442, in StartElementHandler
        raise RuntimeError(name)
    RuntimeError: a
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/vstinner/python/main/Lib/test/test_pyexpat.py", line 472, in test_exception
        self.assertIn('call_with_frame("StartElement"', entries[1][3])
    AssertionError: 'call_with_frame("StartElement"' not found in ''
    
    (...)
    Result: FAILURE
    
  5. vstinner commented on Sep 10, 2023

    @vstinner
    MemberAuthor

    The test checks that the traceback module is able to read a line of the Python C code in Modules/pyexpat.c. The test was added by commit 0ddbf47 in issue #66652 which added _PyTraceback_Add().

    Quickly, the test was skipped if sysconfig.is_python_build() is false: commit 2b3b95b.

    In 2022, the test was skipped on WASM and Win32 ARM: commit 96b344c. These two platforms build Python with cross-compilation: the target Python doesn't have access to Python C source code. A minor follow-up also skipped the test on WASI: commit 9b50585.

    IMO the condition to decide to skip the test or not is weak. And the test should not depend on which directory tests are run.

  6. added 2 commits that reference this issue on Sep 10, 2023
  7. vstinner commented on Sep 10, 2023

    @vstinner
    MemberAuthor

    Oh wait. Maybe it's a real bug in my PR #109229.

    My PR makes the issue easier to reproduce since running the Python test suite with -j1 option changes the current working directory and so trigger the bug.

  8. added 2 commits that reference this issue on Sep 10, 2023
  9. added 2 commits that reference this issue on Sep 10, 2023
  10. added a commit that references this issue on Sep 10, 2023
  11. added a commit that references this issue on Sep 12, 2023
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

    testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions