From 6fafa878f6968af3041ae7265f0ef11854bb254f Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Mon, 18 Aug 2014 16:07:14 +0100 Subject: Deny __iter__ on UserID/RoomID/RoomName instances as it's a subtle bug that will bite you --- synapse/types.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/synapse/types.py b/synapse/types.py index 054b1e713c..b8e191bb3c 100644 --- a/synapse/types.py +++ b/synapse/types.py @@ -32,6 +32,12 @@ class DomainSpecificString( HomeServer as being its own """ + # Deny iteration because it will bite you if you try to create a singleton + # set by: + # users = set(user) + def __iter__(self): + raise ValueError("Attempted to iterate a %s" % (type(self).__name__)) + @classmethod def from_string(cls, s, hs): """Parse the string given by 's' into a structure object.""" -- cgit 1.4.1