Closed
Description
Long story short
Since #2494 , StreamResponse inherits collections.MutableMapping.__eq__, which makes them basically all equal.
The implementation in Mapping looks like return dict(self.items()) == dict(other.items()).
This is especially the case for WebSocketResponse : when following https://aiohttp.readthedocs.io/en/stable/faq.html#how-do-i-programmatically-close-a-websocket-server-side, if you use a list instead of a set, it's impossible to remove the correct websocket.
Expected behaviour
>>> from aiohttp.web_ws import WebSocketResponse
>>> r1 = WebSocketResponse()
>>> r2 = WebSocketResponse()
>>> r1 == r2
False
>>> id(r1) == id(r2)
False
>>> r1 is r2
False
>>> hash(r1) == hash(r2)
FalseAs a rule, a == b implies hash(a) == hash(b). But it's now broken.
Actual behaviour
Since v3.0:
>>> r1 == r2
True
>>> id(r1) == id(r2)
False
>>> r1 is r2
False
>>> hash(r1) == hash(r2)
FalseSteps to reproduce
Described above
Your environment
aiohttp >= 3.0