mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a comment explaining the use of a bytestring for default sort key
This commit is contained in:
parent
dcedc5b87d
commit
d336d75a81
@ -31,7 +31,13 @@ class Field(object):
|
|||||||
self.has_text_data = dt in {'text', 'comments', 'series', 'enumeration'}
|
self.has_text_data = dt in {'text', 'comments', 'series', 'enumeration'}
|
||||||
self.table_type = self.table.table_type
|
self.table_type = self.table.table_type
|
||||||
self._sort_key = (sort_key if dt in ('text', 'series', 'enumeration') else lambda x: x)
|
self._sort_key = (sort_key if dt in ('text', 'series', 'enumeration') else lambda x: x)
|
||||||
|
|
||||||
|
# This will be compared to the output of sort_key() which is a
|
||||||
|
# bytestring, therefore it is safer to have it be a bytestring.
|
||||||
|
# Coercing an empty bytestring to unicode will never fail, but the
|
||||||
|
# output of sort_key cannot be coerced to unicode
|
||||||
self._default_sort_key = b''
|
self._default_sort_key = b''
|
||||||
|
|
||||||
if dt in {'int', 'float', 'rating'}:
|
if dt in {'int', 'float', 'rating'}:
|
||||||
self._default_sort_key = 0
|
self._default_sort_key = 0
|
||||||
elif dt == 'bool':
|
elif dt == 'bool':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user