Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
@jacobian jacobian authored
View
7 django/dispatch/dispatcher.py
@@ -119,10 +119,11 @@ def disconnect(self, receiver=None, sender=None, weak=True, dispatch_uid=None):
lookup_key = (dispatch_uid, _make_id(sender))
else:
lookup_key = (_make_id(receiver), _make_id(sender))
-
- for idx, (r_key, _) in enumerate(self.receivers):
+
+ for index in xrange(len(self.receivers)):
+ (r_key, _) = self.receivers[index]
if r_key == lookup_key:
- del self.receivers[idx]
+ del self.receivers[index]
def send(self, sender, **named):
"""Send signal from sender to all connected receivers.
View
11 tests/modeltests/signals/models.py
@@ -96,4 +96,15 @@ def __call__(self, signal, sender, instance, **kwargs):
>>> models.signals.pre_delete.disconnect(pre_delete_test)
>>> models.signals.post_save.disconnect(post_save_test)
>>> models.signals.pre_save.disconnect(pre_save_test)
+
+# Make sure all the signals got removed properly (#9989)
+>>> models.signals.post_delete.receivers
+[]
+>>> models.signals.pre_delete.receivers
+[]
+>>> models.signals.post_save.receivers
+[]
+>>> models.signals.pre_save.receivers
+[]
+
"""}
Please sign in to comment.
Something went wrong with that request. Please try again.