From: Laurent Bachelier Date: Tue, 23 Oct 2012 04:48:21 +0000 (+0200) Subject: Support tinyifiers with UTF-8 results X-Git-Tag: 1.13~2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bd4c33b732995802e52ac20a719d3a097ebbae4c;p=irker.git Support tinyifiers with UTF-8 results This does not change anything for tinyurl (the default), but allows using http://tinyarro.ws/api-create.php?utfpure=1&url= In case invalid characters are encountered, fall back to str. Signed-off-by: Eric S. Raymond --- diff --git a/irkerhook.py b/irkerhook.py index 8e1a88e..f79ef5f 100755 --- a/irkerhook.py +++ b/irkerhook.py @@ -76,6 +76,10 @@ class Commit: # Didn't get a retrieval error or 404 on the web # view, so try to tinyify a reference to it. self.url = open(urllib.urlretrieve(self.tinyifier + webview)[0]).read() + try: + self.url = self.url.decode('UTF-8') + except UnicodeError: + pass except IOError: self.url = webview else: