Skip to content

Conversation

@picnixz
Copy link
Member

@picnixz picnixz commented Jan 4, 2026

@picnixz picnixz force-pushed the fix/traceback/crash-in-formatting-143377 branch from dfc50e0 to a1512de Compare January 4, 2026 16:35
@picnixz picnixz added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Jan 4, 2026
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍

@picnixz
Copy link
Member Author

picnixz commented Jan 9, 2026

so there is a consistant iOS failure for this test. It looks like unraisable hooks are not well-supported (?) though I don't know why. Who should I ping for help here?

@picnixz
Copy link
Member Author

picnixz commented Jan 9, 2026

ASAN isn't happy either. Which is weird.

@vstinner
Copy link
Member

vstinner commented Jan 9, 2026

The failure on Android, iOS and ASAN:

  ERROR: test_capture_exception_unraisable_exception (test.test_crossinterp.CaptureExceptionTests.test_capture_exception_unraisable_exception)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/data/user/0/org.python.testbed/files/python/lib/python3.15/test/test_crossinterp.py", line 1536, in test_capture_exception_unraisable_exception
      self.assertEqual(cm.unraisable.exc_type, TypeError)
                       ^^^^^^^^^^^^^^^^^^^^^^
  AttributeError: 'NoneType' object has no attribute 'exc_type'

@picnixz
Copy link
Member Author

picnixz commented Jan 9, 2026

Yes but I don't understand why unraisable exceptions are not supported for those platforms. The same goes for ASAN which is an Ubuntu machine. So I'm worried something else is wrong somewhere else but I don't know where.

@vstinner
Copy link
Member

vstinner commented Jan 9, 2026

The failure on Android, iOS and ASAN

Oh, the unraisable exception is only raised if Python is built with --with-pydebug.

Extract of Python/crossinterp.c:

        info->errdisplay = _format_TracebackException(tbexc);
        Py_DECREF(tbexc);
        if (info->errdisplay == NULL) {
#ifdef Py_DEBUG
            PyErr_FormatUnraisable("Exception ignored while formatting TracebackException");
#endif
            PyErr_Clear();
        }

If the Py_DEBUG macro is not defined, PyErr_FormatUnraisable() is not raised.

@picnixz: You can skip the test if test.support.Py_DEBUG is false.

@picnixz
Copy link
Member Author

picnixz commented Jan 9, 2026

Oh I thought all of them were built with DEBUG!

@picnixz
Copy link
Member Author

picnixz commented Jan 9, 2026

Thanks Victor for the investigation! and thanks Serhiy for the suggestions!

@picnixz picnixz merged commit ce6bae9 into python:main Jan 10, 2026
46 checks passed
@picnixz picnixz deleted the fix/traceback/crash-in-formatting-143377 branch January 10, 2026 11:37
@miss-islington-app
Copy link

Thanks @picnixz for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 10, 2026
…thonGH-143418)

(cherry picked from commit ce6bae92da671e31013b00901591ce2b595b61ce)

Co-authored-by: Bénédikt Tran <[email protected]>
@miss-islington-app
Copy link

Sorry, @picnixz, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker ce6bae92da671e31013b00901591ce2b595b61ce 3.13

@bedevere-app
Copy link

bedevere-app bot commented Jan 10, 2026

GH-143652 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Jan 10, 2026
picnixz added a commit to picnixz/cpython that referenced this pull request Jan 10, 2026
…on` (pythonGH-143418)

(cherry picked from commit ce6bae9)

Co-authored-by: Bénédikt Tran <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Jan 10, 2026

GH-143653 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Jan 10, 2026
picnixz added a commit that referenced this pull request Jan 10, 2026
…H-143418) (#143652)

gh-143377: fix crashes in `_interpreters.capture_exception` (GH-143418)
(cherry picked from commit ce6bae9)

Co-authored-by: Bénédikt Tran <[email protected]>
picnixz added a commit that referenced this pull request Jan 10, 2026
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

Successfully merging this pull request may close these issues.

3 participants