From bd4c33b732995802e52ac20a719d3a097ebbae4c Mon Sep 17 00:00:00 2001 From: Laurent Bachelier Date: Tue, 23 Oct 2012 06:48:21 +0200 Subject: [PATCH] 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 --- irkerhook.py | 4 ++++ 1 file changed, 4 insertions(+) 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: -- 2.26.2