Revision: 8770 Author: xqt Date: 2010-12-12 22:47:38 +0000 (Sun, 12 Dec 2010) Log Message: ----------- support of links containing unicode characters (bug # 3135010 patch submitted by ebraminio)
Modified Paths: -------------- trunk/pywikipedia/reflinks.py
Modified: trunk/pywikipedia/reflinks.py =================================================================== --- trunk/pywikipedia/reflinks.py 2010-12-12 22:36:06 UTC (rev 8769) +++ trunk/pywikipedia/reflinks.py 2010-12-12 22:47:38 UTC (rev 8770) @@ -528,7 +528,11 @@ f = None try: socket.setdefaulttimeout(20) - f = urllib2.urlopen(ref.url) + try: + f = urllib2.urlopen(ref.url.decode("utf8")) + except UnicodeError: + ref.url = urllib2.quote(ref.url.encode("utf8"),"://") + f = urllib2.urlopen(ref.url) #Try to get Content-Type from server headers = f.info() contentType = headers.getheader('Content-Type')