#25646: Sort the `local vars` in the rich exception reporter
---------------------------------+------------------------------------
     Reporter:  kezabelle        |                    Owner:
         Type:  New feature      |                   Status:  new
    Component:  Error reporting  |                  Version:  master
     Severity:  Normal           |               Resolution:
     Keywords:                   |             Triage Stage:  Accepted
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  1                |                    UI/UX:  0
---------------------------------+------------------------------------
Changes (by soon):

 * cc: soon (added)


Comment:

 I was going to take this issue, however, I noticed, that variables "should
 be" already sorted in the DEBUG page, because there is a `dictsort` call
 inside template code (line 816, file `django/views/debug.py`):

 {{{
 {% for var in frame.vars|dictsort:"0" %}
 }}}

 However, this call actually does nothing. You may use the following test
 case:


 {{{
 def test_sort_list_of_tuples(self):
     data = [('a', '42'), ('c', 'string'), ('b', 'foo')]
     sorted_data = dictsort(data, '0')

     self.assertEqual([('a', '42'), ('b', 'foo'), ('c', 'string')],
 sorted_data)
 }}}

 And this is the output:


 {{{
 Traceback (most recent call last):
   File ".../django/tests/template_tests/filter_tests/test_dictsort.py",
 line 40, in test_sort_list_of_tuples
     self.assertEqual([('a', '42'), ('b', 'foo'), ('c', 'string')],
 sorted_data)
 AssertionError: Lists differ: [('a', '42'), ('b', 'foo'), ('c', 'string')]
 != [('a', '42'), ('c', 'string'), ('b', 'foo')]

 First differing element 1:
 ('b', 'foo')
 ('c', 'string')

 - [('a', '42'), ('b', 'foo'), ('c', 'string')]
 + [('a', '42'), ('c', 'string'), ('b', 'foo')]
 }}}

 So, I wonder, if this behavior of `dictsort` is correct (according to doc
 comment, the filter accepts a list of dicts, not a list of tuples), or not
 (well, any dict may be presented as list of tuples)?

--
Ticket URL: <https://code.djangoproject.com/ticket/25646#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.f0e6ce1ba30cb2ce8af817330efca56a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to