Skip to content

URIReference and IRIReference inequality can contradict equality #170

Open

Description

@OnlineBunker

On current 3bd3832:

from rfc3986 import uri_reference
a = uri_reference("http://example.test/a")
b = uri_reference("HTTP://EXAMPLE.TEST/a")
print(a == b, a != b)  # True True
print(a == a.unsplit(), a != a.unsplit())  # True True

IRIReference also contradicts equality when compared with its original string. Both classes define __eq__ but inherit tuple's __ne__.

May I take a narrow fix making __ne__ delegate to existing equality, including its TypeError for unsupported comparisons? No equality, hashing or normalization changes are proposed. Hash compatibility needs separate API discussion because existing tests support both raw strings and tuples.

A private 50-case matrix covers both classes, reference/tuple/string inputs and both operand orders: 12 failures and 38 controls on unchanged source, all 50 pass with the draft. The full configured Python 3.12 suite passes 2964 tests with 100% coverage, retaining 1517 warnings.

Prepared with AI assistance. No PR yet; I will wait for scope confirmation.

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