Skip to content

binops between Array and "unknown" types should not always return False #1064

Closed
@gdementen

Description

@gdementen

The return False behavior should only be for == (and True for !=). Related to #988.

>>> object() == object()
False
>>> object() != object()
True

This can be very confusing in some cases, especially for !=:

>>> ndtest(10) != object()
False
>>> ndtest(10) > object()
False
>>> ndtest(10) < object()
False
>>> ndtest(10) + object()
False

Usually comparison operators return TypeError in that case:

>>> object() > object()
TypeError: '>' not supported between instances of 'object' and 'object'

Other arithmetic operations also return TypeError:

>>> object() + object()
TypeError: unsupported operand type(s) for +: 'object' and 'object'

As far as I am concerned, I would use the same message for both cases.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions