Fix #2116784 [author_use_surname_prefixes is always false when surname contains accented character](https://bugs.launchpad.net/calibre/+bug/2116784)

This commit is contained in:
Kovid Goyal 2025-07-13 09:27:40 +05:30
parent acbbe86141
commit 3b762b9781
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 1 deletions

View File

@ -97,7 +97,8 @@ def author_to_author_sort(
author_use_surname_prefixes = tweaks['author_use_surname_prefixes'] if use_surname_prefixes is None else use_surname_prefixes author_use_surname_prefixes = tweaks['author_use_surname_prefixes'] if use_surname_prefixes is None else use_surname_prefixes
if author_use_surname_prefixes: if author_use_surname_prefixes:
author_surname_prefixes = frozenset(x.lower() for x in (tweaks['author_surname_prefixes'] if surname_prefixes is None else surname_prefixes)) author_surname_prefixes = frozenset(
force_unicode(x).lower() for x in (tweaks['author_surname_prefixes'] if surname_prefixes is None else surname_prefixes))
if len(tokens) == 2 and tokens[0].lower() in author_surname_prefixes: if len(tokens) == 2 and tokens[0].lower() in author_surname_prefixes:
return author return author

View File

@ -102,6 +102,9 @@ class TestAuthorToAuthorSort(unittest.TestCase):
self.check_all_methods('Leonardo Da Vinci', self.check_all_methods('Leonardo Da Vinci',
invert='Da Vinci, Leonardo', invert='Da Vinci, Leonardo',
nocomma='Da Vinci Leonardo') nocomma='Da Vinci Leonardo')
self.check_all_methods('Liam Da Mathúna',
invert='Da Mathúna, Liam',
nocomma='Da Mathúna Liam')
self.check_all_methods('Van Gogh') self.check_all_methods('Van Gogh')
self.check_all_methods('Van') self.check_all_methods('Van')
with Tweak('author_use_surname_prefixes', False): with Tweak('author_use_surname_prefixes', False):