forked from openlp/openlp
It appears that when a url encoded in unicode is requested with urllib2.urlopen .getUrl() returns unicode. However the url that we request in the biblegateway importer contains redirects. In this case the redirect uses an utf-8 url (im guessing that) urllib2 takes this as an utf-8 encoded url, so returns getUrl() encoded as utf-8.
bzr-revno: 2180 Fixes: https://launchpad.net/bugs/1251437
This commit is contained in:
commit
6d86abaa37
@ -464,7 +464,11 @@ def get_web_page(url, header=None, update_openlp=False):
|
|||||||
log.debug(u'Downloading URL = %s' % url)
|
log.debug(u'Downloading URL = %s' % url)
|
||||||
try:
|
try:
|
||||||
page = urllib2.urlopen(req)
|
page = urllib2.urlopen(req)
|
||||||
log.debug(u'Downloaded URL = %s' % page.geturl())
|
downloaded_url = page.geturl()
|
||||||
|
# Sometimes we get redirected, in this case page.geturl is encoded in utf-8
|
||||||
|
if not isinstance(downloaded_url, unicode):
|
||||||
|
downloaded_url = downloaded_url.decode('utf-8')
|
||||||
|
log.debug(u'Downloaded URL = %s' % downloaded_url)
|
||||||
except urllib2.URLError:
|
except urllib2.URLError:
|
||||||
log.exception(u'The web page could not be downloaded')
|
log.exception(u'The web page could not be downloaded')
|
||||||
if not page:
|
if not page:
|
||||||
|
Loading…
Reference in New Issue
Block a user