From c39625e2fae6f1a98cb3b177fde2ebca279b607b Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 20 Mar 2013 05:40:32 -0400 Subject: [PATCH] error: Fix ProcessingError message and logging We can't check if message is None if message wasn't an argument to __init__(). Also: * import sys for sys.version * explicitly format strings passed to _LOG.warning(), otherwise you'll get the following: >>> LOG.warning('abc', 'def') Traceback (most recent call last): ... TypeError: not all arguments converted during string formatting Signed-off-by: W. Trevor King --- rss2email/error.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/rss2email/error.py b/rss2email/error.py index e09e73f..95f7209 100644 --- a/rss2email/error.py +++ b/rss2email/error.py @@ -17,6 +17,8 @@ """rss2email-specific errors """ +import sys as _sys + from . import LOG as _LOG from . import __version__, __url__, __email__ @@ -131,7 +133,7 @@ class InvalidFeedName (InvalidFeedConfig): class ProcessingError (FeedError): - def __init__(self, parsed, feed, **kwargs): + def __init__(self, parsed, feed, message=None, **kwargs): if message is None: message = 'error processing feed {}'.format(feed) super(ProcessingError, self).__init__(feed=feed, message=message) @@ -153,10 +155,10 @@ class ProcessingError (FeedError): self.parsed.get('bozo_exception', "can't process"), self.feed.url)) _LOG.warning(_pprint.pformat(self.parsed)) - _LOG.warning('rss2email', __version__) - _LOG.warning('feedparser', _feedparser.__version__) - _LOG.warning('html2text', _html2text.__version__) - _LOG.warning('Python', _sys.version) + _LOG.warning('rss2email {}'.format(__version__)) + _LOG.warning('feedparser {}'.format(_feedparser.__version__)) + _LOG.warning('html2text {}'.format(_html2text.__version__)) + _LOG.warning('Python {}'.format(_sys.version)) _LOG.warning('=== END HERE ===') -- 2.26.2