From b8cb97bd6e2f7232eb19d7cffff01dde7c2535f9 Mon Sep 17 00:00:00 2001 From: Stefan Ritter Date: Wed, 23 Mar 2011 23:55:14 +0100 Subject: Bugfixes for python3: * Use range instead of xrange * Encode unicode objects before hashing --- blogthon.cgi | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/blogthon.cgi b/blogthon.cgi index 1c7c8db..a90ff88 100755 --- a/blogthon.cgi +++ b/blogthon.cgi @@ -39,7 +39,7 @@ line_start_plus = re.compile("^\+.*$") tab = " " def generate_uuid(string): - string_md5sum = md5(string).hexdigest() + string_md5sum = md5(string.encode("utf-8")).hexdigest() string = str.join("-", (string_md5sum[0:8], string_md5sum[8:12], string_md5sum[12:16], string_md5sum[16:20], string_md5sum[20:32])) return string @@ -294,7 +294,7 @@ if feed_display == "atom": print("") j = len(entries) if j > 10: j = 10 - for i in xrange(0, j): + for i in range(0, j): title = str(entries[i][1]).replace(entries_dir, "", 1).replace("." + entries_suffix, "") date = entries[i][0] title_md5sum = generate_uuid(title) @@ -305,7 +305,7 @@ if feed_display == "atom": print(tab*3 + "%s-%s-%sT%s:%s:%sZ" % (str(date[0]), month, day, hour, min, sec)) print(tab*3 + "") content = open(str(entries[i][1]), "r") - for h in xrange(0, int(feed_preview)): + for h in range(0, int(feed_preview)): rss_line = content.readline().strip() if rss_line != "": print(tab*4 + rss_line) @@ -326,7 +326,7 @@ elif feed_display == "rss": print("") j = len(entries) if j > 10: j = 10 - for i in xrange(0, j): + for i in range(0, j): title = str(entries[i][1]).replace(entries_dir, "", 1).replace("." + entries_suffix, "") date = time.strftime("%a, %d %b %Y %H:%M:%S %z", time.gmtime(time.mktime(entries[i][0]))) print(tab*2 + "") @@ -336,7 +336,7 @@ elif feed_display == "rss": print(tab*3 + "%s" % date) content = open(str(entries[i][1]), "r") rss_description= "" - for h in xrange(0, int(feed_preview)): + for h in range(0, int(feed_preview)): line = content.readline().strip() if line: rss_description = "%s%s
" % (rss_description, line) -- cgit v1.2.3