mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 17:24:20 +02:00
Handle undecodable bytes in text columns
This commit is contained in:
parent
d1609037ab
commit
4f5764b1a8
1 changed files with 6 additions and 0 deletions
|
|
@ -52,10 +52,16 @@ def __init__(self, name, metadata, link_table=None):
|
|||
self.name, self.metadata = name, metadata
|
||||
self.sort_alpha = metadata.get('is_multiple', False) and metadata.get('display', {}).get('sort_alpha', False)
|
||||
|
||||
text = lambda x:x.decode('utf-8', 'replace') if isinstance(x, bytes) else x
|
||||
|
||||
# self.unserialize() maps values from the db to python objects
|
||||
self.unserialize = \
|
||||
{
|
||||
'datetime': _c_convert_timestamp,
|
||||
'text': text,
|
||||
'comments': text,
|
||||
'series': text,
|
||||
'enumeration': text,
|
||||
'bool': bool
|
||||
}.get(
|
||||
metadata['datatype'], lambda x: x)
|
||||
|
|
|
|||
Loading…
Reference in a new issue