From b0f80c6d3c2f825717cd06f1693ba2b852a08baa Mon Sep 17 00:00:00 2001 From: pictuga Date: Thu, 9 Apr 2020 19:05:50 +0200 Subject: [PATCH] morss: fix csv output encoding --- morss/feeds.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/morss/feeds.py b/morss/feeds.py index 5859390..98d174f 100644 --- a/morss/feeds.py +++ b/morss/feeds.py @@ -150,15 +150,15 @@ class ParserBase(object): c = csv.writer(out, dialect=csv.excel) for item in self.items: - row = [getattr(item, x) for x in item.dic] - - if encoding != 'unicode': - row = [x.encode(encoding) if isinstance(x, unicode) else x for x in row] - - c.writerow(row) + c.writerow([getattr(item, x) for x in item.dic]) out.seek(0) - return out.read() + out = out.read() + + if encoding != 'unicode': + out = out.encode(encoding) + + return out def tohtml(self, **k): return self.convert(FeedHTML).tostring(**k)