From 3f5df62f0cd20241d150d587595d26e9ae626184 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 21 Mar 2013 11:07:57 -0400 Subject: [PATCH] feed: Add herror to _SOCKET_ERRORS and remove reason handing We don't log the reason, so trying to extract it just gives room for errors to creep in. Luckily, we'll be able to drop the whole _SOCKET_ERRORS thing when we move to Python >= 3.3, because following PEP 3151 the socket errors became subclasses of OSError. Reported-by: Matt Bordignon Signed-off-by: W. Trevor King --- rss2email/feed.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/rss2email/feed.py b/rss2email/feed.py index e5f962d..23b914a 100644 --- a/rss2email/feed.py +++ b/rss2email/feed.py @@ -55,7 +55,7 @@ from . import util as _util _feedparser.USER_AGENT = 'rss2email/{} +{}'.format(__version__, __url__) _urllib_request.install_opener(_urllib_request.build_opener()) _SOCKET_ERRORS = [] -for e in ['error', 'gaierror']: +for e in ['error', 'herror', 'gaierror']: if hasattr(_socket, e): _SOCKET_ERRORS.append(getattr(_socket, e)) del e # cleanup namespace @@ -363,16 +363,10 @@ class Feed (object): if isinstance(exc, _socket.timeout): _LOG.error('timed out: {}'.format(self)) warned = True - elif isinstance(exc, _SOCKET_ERRORS): - reason = exc.args[1] + elif isinstance(exc, OSError): _LOG.error('{}: {}'.format(exc, self)) warned = True - elif (hasattr(exc, 'reason') and - isinstance(exc.reason, _urllib_error.URLError)): - if isinstance(exc.reason, _SOCKET_ERRORS): - reason = exc.reason.args[1] - else: - reason = exc.reason + elif isinstance(exc, _SOCKET_ERRORS): _LOG.error('{}: {}'.format(exc, self)) warned = True elif isinstance(exc, _feedparser.zlib.error): -- 2.26.2