Also decode bytes in comparable_price()

This commit is contained in:
Kovid Goyal 2023-10-03 07:40:27 +05:30
parent da24ae6480
commit 503d0e0113
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -22,6 +22,8 @@ from calibre.utils.search_query_parser import SearchQueryParser
def comparable_price(text): def comparable_price(text):
if isinstance(text, (int, float)): if isinstance(text, (int, float)):
text = str(text) text = str(text)
if isinstance(text, bytes):
text = text.decode('utf-8', 'ignore')
text = text or '' text = text or ''
# this keep thousand and fraction separators # this keep thousand and fraction separators
match = re.search(r'(?:\d|[,.](?=\d))(?:\d*(?:[,.\' ](?=\d))?)+', text) match = re.search(r'(?:\d|[,.](?=\d))(?:\d*(?:[,.\' ](?=\d))?)+', text)