forked from github/pelican
Merge pull request #1308 from al-tonio/download_attachments_japanese_error_msg_fix
Fix error in download_attachments() triggered by python2 unit test
This commit is contained in:
commit
de9ef74479
1 changed files with 12 additions and 2 deletions
|
|
@ -603,8 +603,18 @@ def download_attachments(output_path, urls):
|
|||
.format(url, e))
|
||||
logger.warning(error)
|
||||
except IOError as e: #Python 2.7 throws an IOError rather Than URLError
|
||||
error = ("No file could be downloaded from {}; Error {}"
|
||||
.format(url, e))
|
||||
# For japanese, the error might look kind of like this:
|
||||
# e = IOError( 'socket error', socket.error(111, u'\u63a5\u7d9a\u3092\u62d2\u5426\u3055\u308c\u307e\u3057\u305f') )
|
||||
# and not be suitable to use in "{}".format(e) , raising UnicodeDecodeError
|
||||
# (This is at least the case on my Fedora running Python 2.7.5
|
||||
# (default, Feb 19 2014, 13:47:28) [GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] on linux2
|
||||
try:
|
||||
error = ("No file could be downloaded from {}; Error {}"
|
||||
.format(url, e))
|
||||
except UnicodeDecodeError:
|
||||
# For lack of a better log message because we could not decode e, let's use repr(e)
|
||||
error = ("No file could be downloaded from {}; Error {}"
|
||||
.format(url, repr(e)))
|
||||
logger.warning(error)
|
||||
return locations
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue