﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
20963	"order_by interaction with ""brew"" distribution of Python 2.7.5 introduces edge-case regression"	Preston Holmes	nobody	"This commit:

https://github.com/django/django/commit/69597e5bcc89aadafd1b76abf7efab30ee0b8b1a

introduced a change that interacts with the OS X specific ""brew"" installation of Python 2.7.5 to result in a regression in one test.

{{{
FAIL: test_tickets_2076_7256 (regressiontests.queries.tests.Queries1Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File ""/Users/admin/Desktop/django/tests/regressiontests/queries/tests.py"", line 437, in test_tickets_2076_7256
    ['<Item: one>', '<Item: two>', '<Item: one>', '<Item: two>', '<Item: four>']
  File ""/Users/admin/Desktop/django/django/test/testcases.py"", line 776, in assertQuerysetEqual
    return self.assertEqual(list(items), values)
AssertionError: Lists differ: [] != [u'<Item: one>', u'<Item: two>...
 
Second list contains 5 additional elements.
First extra element 0:
<Item: one>
 
- []
+ [u'<Item: one>',
+  u'<Item: two>',
+  u'<Item: one>',
+  u'<Item: two>',
+  u'<Item: four>']
 
----------------------------------------------------------------------
Ran 1 test in 0.033s
 
FAILED (failures=1)
}}}

This is limited only to this patched distribution of Python. Unfortunately this is a rather common version to be running on developer machines.

This gist shows this error on a clean machine with the brew version of 2.7.5, and the python.org binary install version of 2.7.5

The crux of the issue can be seen in this PDB session started from the failing test:

{{{
(Pdb) Item.objects.filter(tags__isnull=False)
[<Item: four>, <Item: one>, <Item: one>, <Item: two>, <Item: two>]
(Pdb) Item.objects.filter(tags__isnull=False).order_by('tags')
[]
}}}
"	Bug	new	Database layer (models, ORM)	1.6-beta-1	Normal				Unreviewed	0	0	0	0	0	0
