From 102aa487085a5451599909232e1d2a38b3d83857 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 30 Oct 2008 19:18:37 -0700 Subject: [PATCH] Fix #1214 (Feeds2lrf crash when downloading http://rss.gazeta.pl/pub/rss/gazetawyborcza.xml) --- src/calibre/ebooks/html.py | 5 ++++- src/calibre/library/test.py | 2 ++ src/calibre/web/feeds/news.py | 6 ++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/html.py b/src/calibre/ebooks/html.py index afef1291d3..e9b4d06de4 100644 --- a/src/calibre/ebooks/html.py +++ b/src/calibre/ebooks/html.py @@ -573,7 +573,10 @@ class Processor(Parser): style.tail = '\n' path = os.path.join(os.path.dirname(self.save_path()), *(style.get('href').split('/'))) self.resource_map[path] = style.get('href') - open(path, 'wb').write(getattr(sheet, 'cssText', sheet).encode('utf-8')) + raw = getattr(sheet, 'cssText', sheet) + if isinstance(raw, unicode): + raw = raw.encode('utf-8') + open(path, 'wb').write(raw) return Parser.save(self) def populate_toc(self, toc): diff --git a/src/calibre/library/test.py b/src/calibre/library/test.py index 3065e4eec0..1a81755971 100644 --- a/src/calibre/library/test.py +++ b/src/calibre/library/test.py @@ -72,6 +72,8 @@ class DBTest(unittest.TestCase): self.assertEqual(getattr(self.db, x)(2), val) self.db.set_authors(3, ['new auth']) + self.db.refresh_ids([3]) + self.assertEqual('new auth', self.db.authors(2)) self.assertEqual(self.db.format(3, 'txt', index_is_id=True), 'test') diff --git a/src/calibre/web/feeds/news.py b/src/calibre/web/feeds/news.py index 13d7d0eb19..c7fb812508 100644 --- a/src/calibre/web/feeds/news.py +++ b/src/calibre/web/feeds/news.py @@ -541,8 +541,10 @@ class BasicNewsRecipe(object, LoggingInterface): npos = max(si, gi) if npos < 0: npos = pos - - return src[:npos+1]+u'\u2026' + ans = src[:npos+1] + if isinstance(ans, unicode): + return + return ans+u'\u2026' if isinstance(ans, unicode) else ans + '...'