#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
---------------------------------+------------------------------------

Comment (by soon):

 Replying to [comment:4 bmispelon]:
 > You might be on to something.
 >
 > I did a quick regression testing and it seems that sorting of tuples
 worked in 1.2 but was broken in 1.3 by
 561af6417e1c8232904b726fb0219cc0b7c2e71d (though I don't really understand
 how this particular commit could have broken it).

 Seems like `Variable('0').resolve(context)` returns `0` regardless of
 given `context`, that is why sorting by `key=Variable('0').resolve` does
 not work. Transferring each item into a tuple of `(var_resolve(item),
 item)` allows us to order tuples by their second element, if the first
 elements are equal. However, this approach will fail, when the `item` is
 of unorderable type (see the test case below).

 Note also: function `dictsort` will fail for dictionaries with numeric
 keys :

 {{{
 def test_sort_list_of_tuple_like_dicts(self):
     data = [{'0': 'a', '1': '42'},
             {'0': 'c', '1': 'string'},
             {'0': 'b', '1': 'foo'}]

     sorted_data = dictsort(data, '0')

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

 }}}


 > `dictsort` is used in a few other places in the
 [https://github.com/django/django/blob/master/django/views/debug.py#L1110
 debug view] and I think all of them are also broken.
 >
 > Considering this, I think the best approach would be to restore the
 functionality of sorting tuples, test it and document it.
 > What do you think?

 Yes, I sure, this is the right approach. Should we make a new ticket for
 `dictsort` changes?

--
Ticket URL: <https://code.djangoproject.com/ticket/25646#comment:5>
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.d9c41b8c588b7af5d410bcb19e9a46a0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to