summary refs log tree commit diff
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2014-08-18 16:07:14 +0100
committerPaul "LeoNerd" Evans <paul@matrix.org>2014-08-19 11:16:23 +0100
commit6fafa878f6968af3041ae7265f0ef11854bb254f (patch)
treed5f123866790db4a738a01837467016252475319
parentRename MockHttpServer to MockHttpResource as it stands for one server resourc... (diff)
downloadsynapse-6fafa878f6968af3041ae7265f0ef11854bb254f.tar.xz
Deny __iter__ on UserID/RoomID/RoomName instances as it's a subtle bug that will bite you
-rw-r--r--synapse/types.py6
1 files changed, 6 insertions, 0 deletions
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."""