Skip to content

fix(protocols): Schema display and iteration follow PyPy's attribute layout, not the declared fields #2008

Closed as not planned

Description

@JarryShaw

Schema takes the field order for __str__, __repr__ and __iter__ from the instance's __dict__. On PyPy, an instance's attributes follow the layout of an earlier instance of the same class, so a later schema can display or iterate its fields out of declared order. Packed bytes are unaffected: packing follows the declared fields.

This is the same cause as #2003, which fixed it for Info by recording the order at construction. Found while working on #2003.

Fix: derive the display and iteration order from the declared fields, not from __dict__. Add a test that reorders an instance's __dict__ on CPython to simulate PyPy.

Activity

  1. added
    bugIssues reporting a defect (set by the bug report template; a default, not an assessment)
    fixPull requests that fix a defect (fix: subject prefix)
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 20, 2026
  2. moved this to Pending in PyPCAPKiton Oct 20, 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 20, 2026
  4. moved this from Pending to WIP in PyPCAPKiton Oct 20, 2026
  5. JarryShaw commented on Oct 20, 2026

    @JarryShaw
    OwnerAuthor

    Closing as not planned. Per your note on #2009, attribute order isn't required, and a check found nothing that depends on it in Schema:

    • pack, unpack and __bytes__ walk the declared fields and read values by key;
    • to_dict keeps the same keys and values;
    • equality compares plain dicts.

    On PyPy, only display and iteration order change.

  6. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 20, 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)fixPull requests that fix a defect (fix: subject prefix)

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions