From 173023024432715e84b9fdd819613dcc10999593 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sun, 29 Oct 2017 11:12:56 +0000 Subject: [PATCH] [#3124|GTKUI] Fix comparing Name str if value is None The original fix was not correct as the strcoll function cannot accept None only strings. This fix ensures that the value is an empty string if None for comparison. --- deluge/ui/gtkui/torrentview.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/deluge/ui/gtkui/torrentview.py b/deluge/ui/gtkui/torrentview.py index 9e24428f8..7adc6c2f4 100644 --- a/deluge/ui/gtkui/torrentview.py +++ b/deluge/ui/gtkui/torrentview.py @@ -30,17 +30,17 @@ CTRL_ALT_MASK = CONTROL_MASK | MOD1_MASK def str_nocase_sort(model, iter1, iter2, data): - """ - Sort string column data with locale.strcoll which (allegedly) uses ISO 14651. + """Sort string column data using ISO 14651 in lowercase. + + Uses locale.strcoll which (allegedly) uses ISO 14651. Compares first + value with second and returns -1, 0, 1 for where it should be placed. """ - try: - v1 = model[iter1][data].lower() - v2 = model[iter2][data].lower() - except AttributeError: - # Catch None type for value. - v1 = model[iter1][data] - v2 = model[iter2][data] + v1 = model[iter1][data] + v2 = model[iter2][data] + # Catch any values of None from model. + v1 = v1.lower() if v1 else '' + v2 = v2.lower() if v2 else '' return strcoll(v1, v2)