Skip to content

fix(ipv4): TS option maker rejects its own default timestamp=None and prints it without !r #2277

Closed

Description

@JarryShaw

Describe the bug
IPv4._make_opt_ts accepts only a list or a dict for timestamp, but its default is None. So a TS option built without timestamps always falls through to the error branch. That branch formats with {timestamp} rather than {timestamp!r} (#2232, #2257), so 'abc' renders as a bare word, and the docstring's Raises: lists only FieldValueError.

Reproduction

IPv4(src='1.2.3.4', dst='5.6.7.8', options=[(OptionNumber.TS, {})])
# ProtocolError: IPv4: [OptNo 68] invalid timestamp value: None
IPv4.__new__(IPv4)._make_opt_ts(OptionNumber.TS, timestamp='abc')
# ProtocolError: IPv4: [OptNo 68] invalid timestamp value: abc

timestamp=[] builds: length 24, pointer 5.

Expected behavior
timestamp=None builds like [], a Timestamp-only option with counts empty slots. Anything else that is not a list or a dict raises IPv4: [OptNo 68] invalid timestamp value: must be a list or a dict, not 'abc'. Suggested fix: treat None as [] before the type dispatch, use !r, and add ProtocolError to Raises:. test_ipv4_unit asserts assertRaises(ProtocolError) for timestamp=None, so that case flips; no test pins the text.

System information
Linux, CPython 3.14.9, pcapkit 1.5.0b14 at main 9d504ead5.

Activity

  1. added this to the PyPCAPKit v1.5 milestone on Oct 26, 2026
  2. added
    bugIssues reporting a defect (set by the bug report template; a default, not an assessment)
    on Oct 26, 2026
  3. moved this to Pending in PyPCAPKiton Oct 26, 2026
  4. added
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 26, 2026
  5. moved this from Pending to WIP in PyPCAPKiton Oct 26, 2026
  6. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 27, 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