Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#10753 closed (fixed)

Test client fails after 10398

Reported by: Ville Säävuori Owned by: Adrian Holovaty
Component: Core (Other) Version: dev
Severity: Keywords: testing signals
Cc: ratsam@…, minmax@…, sopelkin@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

After changeset r10398 my tests started failing for an app that uses signals. (post_save signal in this case -- nothing special in there)

Traceback from the test client:

Traceback (most recent call last):
  File "/home/syneusfi/new_intra/pylib/heimlich/tests.py", line 142, in test_ticket_creation
    response = self.client.post('/partiovaruste/bugilista/uusi/', postdata)
  File "/home/syneusfi/django/django/test/client.py", line 306, in post
    response = self.request(**r)
  File "/home/syneusfi/django/django/test/client.py", line 224, in request
    response = self.handler(environ)
  File "/home/syneusfi/django/django/test/client.py", line 75, in __call__
    signals.request_finished.disconnect(close_connection)
  File "/home/syneusfi/django/django/dispatch/dispatcher.py", line 124, in disconnect
    (r_key, _) = self.receivers[index]
IndexError: list index out of range

The tests in question pass for revision r10397. I tested that they also pass when reverting only django/django/dispatch/dispatcher.py to the previous revision, so I'm quite confident that r10398 broke something here.

Attachments (2)

dj.patch (1.2 KB ) - added by Karataev Pavel 16 years ago.
fix.diff (1.4 KB ) - added by Karataev Pavel 16 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 by Russell Keith-Magee, 16 years ago

Any chance you could give us an example of a test that is actually failing? It's great to know that you have a test that is failing, but unless you can give us the actual test, it is a lot more difficult to diagnose what is going on here.

comment:2 by ratsam, 16 years ago

Cc: ratsam@… added

comment:3 by Karataev Pavel, 16 years ago

Cc: minmax@… sopelkin@… added
Owner: changed from nobody to Karataev Pavel
Status: newassigned

see http://code.djangoproject.com/changeset/10398 dispatcher.py

example:

In [1]: l = [1,2,3]
In [2]: for i in xrange(len(l)):

...: del l[i]


IndexError Traceback (most recent call last)

IndexError: list assignment index out of range

by Karataev Pavel, 16 years ago

Attachment: dj.patch added

comment:4 by Karataev Pavel, 16 years ago

Resolution: fixed
Status: assignedclosed

see attachment

comment:5 by Russell Keith-Magee, 16 years ago

Resolution: fixed
Status: closedreopened
  1. This isn't fixed until the patch is applied to trunk.
  2. The patch doesn't contain a test case.
  3. The test case you have provided in the comments is pure python - it doesn't contain any Django code. The example breaks for a very good reason - after deleting two items from the list, there isn't an l[2] to delete. This is purely normal python behaviour.

in reply to:  1 comment:6 by Ville Säävuori, 16 years ago

Replying to russellm:

Any chance you could give us an example of a test that is actually failing?

I wrote a small test project + testapp to demonstrate this but I couldn't reproduce the bug in there. I'll try to strip out the problematic app+test from the original project next.

Weird thing is, this was the only test that broke in dozens of projects with lots of tests. But I'm still quite sure it's a bug in Django.

comment:7 by Karataev Pavel, 16 years ago

This issue occurs when there are more than one listener and the last one is disconnected.

test case with django:

s = Signal()
r1 = lambda kw: None
r2 = lambda
kw: None
s.connect(r1)
s.connect(r2)
s.disconnect(r1)

Traceback (most recent call last):

File "<console>", line 1, in <module>
File "/home/minmax/projects/lib/django/dispatch/dispatcher.py", line 124, in disconnect

(r_key, _) = self.receivers[index]

IndexError: list index out of range

comment:8 by Karataev Pavel, 16 years ago

sorry

>>> s = Signal()
>>> r1 = lambda **kw: None
>>> r2 = lambda **kw: None
>>> s.connect(r1)
>>> s.connect(r2)
>>> s.disconnect(r1)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/minmax/projects/lib/django/dispatch/dispatcher.py", line 124, in disconnect
    (r_key, _) = self.receivers[index]
IndexError: list index out of range

by Karataev Pavel, 16 years ago

Attachment: fix.diff added

comment:9 by Adrian Holovaty, 16 years ago

Component: UncategorizedCore framework
Owner: changed from Karataev Pavel to Adrian Holovaty
Status: reopenednew
Triage Stage: UnreviewedAccepted

I'm getting this error as well, after [10398]. Thanks for the patch -- I'm going to take a look.

comment:10 by Adrian Holovaty, 16 years ago

Resolution: fixed
Status: newclosed

(In [10497]) Fixed #10753 -- Fixed regression in dispatcher after [10398]. Thanks for the patch and tests, minmax

comment:11 by Jacob, 16 years ago

(In [10503]) [1.0.X] Fixed #10753 -- Fixed regression in dispatcher after [10398]. Thanks for the patch and tests, minmax. Backport of r10497 from trunk.

comment:12 by Jacob, 13 years ago

milestone: 1.1

Milestone 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top