Skip to content

[P2] PyNeoDeviceEx equality ignores serial number and equates different devices #246

Description

@drebbe-intrepid

Bug

__eq__ compares device and firmware fields but omits SerialNumber. Two otherwise identical discovered devices with different serials compare equal, breaking membership checks and list-based deduplication.

Reviewed commit: 45167e09de6b886cd451a4245f842c8221349711 (current master on 2026-09-15).
Source: src/ics/py_neo_device_ex.py:28

Reproduction

import ics
a, b = ics.PyNeoDeviceEx(), ics.PyNeoDeviceEx()
a._auto_handle_close = b._auto_handle_close = False
a.neoDevice.SerialNumber = 100
b.neoDevice.SerialNumber = 200
print(a == b)
print(b in [a])

Observed / expected

Both comparisons are True. Expected different device identities to compare unequal. No hardware or open handle is required.

Suggested fix and regression coverage

Include the serial number in the equality contract and return NotImplemented for unrelated types. Add tests for same model/different serials, equal device snapshots, and comparisons to unrelated objects.

Validation environment

Windows x64, CPython 3.14.5, extension rebuilt from the commit above. Hardware-dependent entry points below were exercised with a mock DLL, not a connected device. The existing 30 tests pass despite these findings.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions