Skip to content

fix(utilities): the threading excepthook falls back to threading.__excepthook__, which Python 3.8 and 3.9 lack #1691

Closed

Description

@JarryShaw

Describe the bug
threading.__excepthook__ was added in Python 3.10, but requires-python is >=3.6. Two library lines call it:

  • pcapkit/utilities/exceptions.py:355, the re-entrancy fallback.
  • pcapkit/utilities/exceptions.py:371, when no previous hook was saved.

On 3.8 and 3.9 the fallback therefore raises AttributeError: module 'threading' has no attribute '__excepthook__' from inside threading.excepthook. The tests use it as well, at tests/utilities/test_exceptions_excepthook.py:546, :606 and :651.

Reproduction
Four ThreadingExcepthookTests tests fail on both legs.

  • Library: test_a_reentrant_threading_delegate_falls_back_instead_of_recursing. The traceback ends at exceptions.py:355.
  • Test-side, where the library delegates correctly and PREVIOUS_THREADING_HOOK_RAN prints first:
    • test_a_loud_base_error_on_a_thread_matches_the_old_two_line_shape
    • test_a_chained_error_on_a_thread_also_matches_the_old_shape
    • test_a_non_base_error_on_a_thread_is_delegated_to_the_previous_hook

No test reaches :371.

Expected behavior
Before 3.10, fall back to the default hook that threading.excepthook held at import, in the library and in the tests alike.

Found while triaging main's KTLO legs at f20d0a600: Python 3.8 (KTLO) job 115570853800 (27 failed) and Python 3.9 (KTLO) job 115570853966 (9 failed). Since #1672, KTLO legs exit 0, so this shows only as a ::warning. Reproduced locally on CPython 3.8.20 and 3.9.25.

Activity

  1. added
    fixPull requests that fix a defect (fix: subject prefix)
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 14, 2026
  2. moved this to Pending in PyPCAPKiton Oct 14, 2026
  3. added
    wipWork in flight - a covering PR is open or an agent is actively on it
    and removed
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 14, 2026
  4. moved this from Pending to WIP in PyPCAPKiton Oct 14, 2026
  5. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 14, 2026
  6. added this to the PyPCAPKit v1.5 milestone on Oct 26, 2026
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

    fixPull requests that fix a defect (fix: subject prefix)

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions