Skip to content

fix(foundation): the pypcap engine raises a pcap loader's OSError instead of falling back as pcap_ct does #2132

Closed

Description

@JarryShaw

pcapkit.extract(engine='pypcap') raises the loader's OSError when a pcap module is installed but cannot load. That happens, for example, with pcap-ct on macOS (dlopen(libc.so.6 …)), on Windows without Npcap (Cannot find npcap/wpcap.dll), or on Linux without libpcap.so. The same situation with engine='pcap_ct' warns and falls back to the default engine.

Cause: PyPCAP._reason_for in pcapkit/foundation/engines/pypcap.py only returns _pcap_backend.wrong_backend_reason(...). PCAP_CT._reason_for also reports a probe whose module is installed but unusable (found.name is None and not found.missing), with the OSError as the reason.

Reproduced in the #2131 review with a fake pcap package whose import raises OSError('Cannot find libpcap.so library'), put on sys.path in a subprocess:

  • engine='pcap_ct' warns and falls back.
  • engine='pypcap' raises OSError.

Found while root-causing #2129, whose benchmark-side workaround is #2131.

Fix: give PyPCAP._reason_for the same installed-but-unusable branch, or move that branch into a helper in _pcap_backend that both engines call. Add a test with a fake pcap package that fails without the fix.

Activity

  1. added
    bugIssues reporting a defect (set by the bug report template; a default, not an assessment)
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 24, 2026
  2. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 24, 2026
  3. 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

    bugIssues reporting a defect (set by the bug report template; a default, not an assessment)

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions