From 0035170828612fba5c7325c8e796447bd494831c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 30 Oct 2020 20:49:21 +0530 Subject: [PATCH] ebook-meta: fix an error when using an rmpty string as the rating on epub 2 --- src/calibre/ebooks/metadata/opf2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/ebooks/metadata/opf2.py b/src/calibre/ebooks/metadata/opf2.py index 162fce79df..1832f073b2 100644 --- a/src/calibre/ebooks/metadata/opf2.py +++ b/src/calibre/ebooks/metadata/opf2.py @@ -1315,7 +1315,7 @@ class OPF(object): # {{{ val = getattr(mi, attr, None) if attr == 'rating' and val: val = float(val) - is_null = val is None or val in ((), [], (None, None), {}) or (attr == 'rating' and val < 0.1) + is_null = val is None or val in ((), [], (None, None), {}) or (attr == 'rating' and (not val or val < 0.1)) if is_null: if apply_null and attr in {'series', 'tags', 'isbn', 'comments', 'publisher', 'rating'}: setattr(self, attr, ([] if attr == 'tags' else None))