Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #9989: fixed a subtle edge case where removing signals could br…

…eak. Thanks, ferringb.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10398 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 20b598bf3e430ac969f06c290ab69555b9604922 1 parent df7ffe6
Jacob Kaplan-Moss authored April 05, 2009
7  django/dispatch/dispatcher.py
@@ -119,10 +119,11 @@ def disconnect(self, receiver=None, sender=None, weak=True, dispatch_uid=None):
119 119
             lookup_key = (dispatch_uid, _make_id(sender))
120 120
         else:
121 121
             lookup_key = (_make_id(receiver), _make_id(sender))
122  
-
123  
-        for idx, (r_key, _) in enumerate(self.receivers):
  122
+        
  123
+        for index in xrange(len(self.receivers)):
  124
+            (r_key, _) = self.receivers[index]
124 125
             if r_key == lookup_key:
125  
-                del self.receivers[idx]
  126
+                del self.receivers[index]
126 127
 
127 128
     def send(self, sender, **named):
128 129
         """Send signal from sender to all connected receivers.
11  tests/modeltests/signals/models.py
@@ -96,4 +96,15 @@ def __call__(self, signal, sender, instance, **kwargs):
96 96
 >>> models.signals.pre_delete.disconnect(pre_delete_test)
97 97
 >>> models.signals.post_save.disconnect(post_save_test)
98 98
 >>> models.signals.pre_save.disconnect(pre_save_test)
  99
+
  100
+# Make sure all the signals got removed properly (#9989)
  101
+>>> models.signals.post_delete.receivers
  102
+[]
  103
+>>> models.signals.pre_delete.receivers
  104
+[]
  105
+>>> models.signals.post_save.receivers
  106
+[]
  107
+>>> models.signals.pre_save.receivers
  108
+[]
  109
+
99 110
 """}

0 notes on commit 20b598b

Please sign in to comment.
Something went wrong with that request. Please try again.