py3: fix sorting dictionaries when some of their names might be None

This commit is contained in:
Kovid Goyal 2019-05-01 17:25:34 +05:30
parent 1473f4a83e
commit 6f355b5297
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -8,7 +8,6 @@ __copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
import os, glob, shutil, re, sys
from collections import namedtuple, defaultdict
from operator import attrgetter
from itertools import chain
from functools import partial
@ -159,7 +158,7 @@ def get_dictionary(locale, exact_match=False):
# Now just return any dictionary that matches the language, preferring user
# installed ones to builtin ones
for collection in (custom_dictionaries(), builtin_dictionaries()):
for d in sorted(collection, key=attrgetter('name')):
for d in sorted(collection, key=lambda d: d.name or ''):
if d.primary_locale.langcode == locale.langcode:
return d