From c33dd1244934b518f35f20f2824904358480f8a7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 5 May 2014 20:31:25 +0530 Subject: [PATCH] Edit Book: Fix error when checking spelling if one of the files in the book declares an invalid (empty) language code. Fixes #1316170 [Spellcheck doesn't like ...xml:lang=""](https://bugs.launchpad.net/calibre/+bug/1316170) --- src/calibre/ebooks/oeb/polish/spell.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/oeb/polish/spell.py b/src/calibre/ebooks/oeb/polish/spell.py index f599f55579..7fc7542ba7 100644 --- a/src/calibre/ebooks/oeb/polish/spell.py +++ b/src/calibre/ebooks/oeb/polish/spell.py @@ -128,11 +128,17 @@ def read_words_from_html_tag(tag, words, file_name, parent_locale, locale): def locale_from_tag(tag): if 'lang' in tag.attrib: - loc = parse_lang_code(tag.get('lang')) + try: + loc = parse_lang_code(tag.get('lang')) + except ValueError: + loc = None if loc is not None: return loc if '{http://www.w3.org/XML/1998/namespace}lang' in tag.attrib: - loc = parse_lang_code(tag.get('{http://www.w3.org/XML/1998/namespace}lang')) + try: + loc = parse_lang_code(tag.get('{http://www.w3.org/XML/1998/namespace}lang')) + except ValueError: + loc = None if loc is not None: return loc