Code

Opened 5 years ago

Closed 5 years ago

Last modified 3 years ago

#10753 closed (fixed)

Test client fails after 10398

Reported by: Uninen Owned by: adrian
Component: Core (Other) Version: master
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: UI/UX:

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 minmax 5 years ago.
fix.diff (1.4 KB) - added by minmax 5 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 follow-up: Changed 5 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 Changed 5 years ago by ratsam

  • Cc ratsam@… added

comment:3 Changed 5 years ago by minmax

  • Cc minmax@…, sopelkin@… added
  • Owner changed from nobody to minmax
  • Status changed from new to assigned

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

Changed 5 years ago by minmax

comment:4 Changed 5 years ago by minmax

  • Resolution set to fixed
  • Status changed from assigned to closed

see attachment

comment:5 Changed 5 years ago by russellm

  • Resolution fixed deleted
  • Status changed from closed to reopened
  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.

comment:6 in reply to: ↑ 1 Changed 5 years ago by Uninen

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 Changed 5 years ago by minmax

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 Changed 5 years ago by minmax

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

Changed 5 years ago by minmax

comment:9 Changed 5 years ago by adrian

  • Component changed from Uncategorized to Core framework
  • Owner changed from minmax to adrian
  • Status changed from reopened to new
  • Triage Stage changed from Unreviewed to Accepted

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

comment:10 Changed 5 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:11 Changed 5 years ago by jacob

(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 Changed 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.