From 763d9a88f611428fa5b2b0c3503486ba315e07ae Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 28 Feb 2014 13:51:15 -0800 Subject: [PATCH] command: Set the 'feed' argument when raising NoToEmailAddress Before this commit, if no default target email was setup in the config: $ r2e add example http://example.net/ Traceback (most recent call last): File "/usr/bin/r2e", line 5, in rss2email.main.run() File "/usr/lib/python3/dist-packages/rss2email/main.py", line 163, in run args.func(feeds=feeds, args=args) File "/usr/lib/python3/dist-packages/rss2email/command.py", line 50, in add raise _error.NoToEmailAddress(feeds=feeds) TypeError: __init__() missing 1 required positional argument: 'feed' After this commit: $ r2e add example http://example.net/ no target email address has been defined I added the kwargs handling to FeedError so it will be passed through to FeedsError because NoToEmailAddress has a diamond-inheritence that includes both RSS2EmailError subclasses. Reported-by: Jakub Wilk Signed-off-by: W. Trevor King --- rss2email/command.py | 2 +- rss2email/error.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rss2email/command.py b/rss2email/command.py index 038b83f..acf6295 100644 --- a/rss2email/command.py +++ b/rss2email/command.py @@ -47,7 +47,7 @@ def add(feeds, args): feed = feeds.new_feed(name=args.name, url=args.url, to=args.email) _LOG.info('add new feed {}'.format(feed)) if not feed.to: - raise _error.NoToEmailAddress(feeds=feeds) + raise _error.NoToEmailAddress(feed=feed, feeds=feeds) feeds.save() def run(feeds, args): diff --git a/rss2email/error.py b/rss2email/error.py index b5ad130..f9adf65 100644 --- a/rss2email/error.py +++ b/rss2email/error.py @@ -135,10 +135,10 @@ class SendmailError (RSS2EmailError): class FeedError (RSS2EmailError): - def __init__(self, feed, message=None): + def __init__(self, feed, message=None, **kwargs): if message is None: message = 'error with feed {}'.format(feed.name) - super(FeedError, self).__init__(message=message) + super(FeedError, self).__init__(message=message, **kwargs) self.feed = feed -- 2.26.2