Fixed #9989: fixed a subtle edge case where removing signals could break. Thanks, ferringb.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10398 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
df7ffe616a
commit
20b598bf3e
|
@ -119,10 +119,11 @@ class Signal(object):
|
|||
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.
|
||||
|
|
|
@ -96,4 +96,15 @@ instance.id is None: False
|
|||
>>> 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
|
||||
[]
|
||||
|
||||
"""}
|
||||
|
|
Loading…
Reference in New Issue