Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: abp/filters/sources.py

Issue 29968569: Issue 4014 - Publish python-abp on PyPI (Closed) Base URL: https://hg.adblockplus.org/python-abp/
Patch Set: Created Dec. 27, 2018, 11:31 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: abp/filters/sources.py
===================================================================
--- a/abp/filters/sources.py
+++ b/abp/filters/sources.py
@@ -21,7 +21,8 @@
try:
from urllib2 import urlopen, HTTPError
-except ImportError: # The module was renamed in Python 3.
+except ImportError: # pragma: no py2 cover
+ # The module was renamed in Python 3
from urllib.request import urlopen
from urllib.error import HTTPError
@@ -174,8 +175,10 @@
encoding = get_param('charset') or self.default_encoding
for line in response:
yield line.decode(encoding).rstrip()
- except HTTPError as err:
- if err.code == 404:
- raise NotFound("HTTP 404 Not found: '{}:{}'"
- .format(self.protocol, path_in_source))
- raise err
+ except (HTTPError, ValueError) as err:
+ try:
+ if err.code == 404:
+ raise NotFound("HTTP 404 Not found: '{}:{}'"
+ .format(self.protocol, path_in_source))
+ except AttributeError: # Need to catch so the real err is raised
+ raise err
Sebastian Noack 2018/12/28 00:22:51 Previously, when we got an HTTPError with a code o
rhowell 2018/12/28 21:50:07 Ah, you're right, thanks.
« LICENSE ('K') | « LICENSE ('k') | setup.py » ('j') | setup.py » ('J')

Powered by Google App Engine
This is Rietveld