From 113b466e96a994dbc0eeff70b57d319f1fe2462d Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Sun, 7 Jul 2019 11:03:59 +0000 Subject: [PATCH] utf-8 workaround for python 2.x --- lib/fmt/comments.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/fmt/comments.py b/lib/fmt/comments.py index d658f48..a603e82 100644 --- a/lib/fmt/comments.py +++ b/lib/fmt/comments.py @@ -261,6 +261,8 @@ def code_blocks(text, wrap_lines=False, unindent_code=False): Split `text` into blocks of text and code. Return list of tuples TYPE, TEXT """ + text = text.encode('utf-8') + lines = [x.rstrip('\n') for x in text.splitlines()] lines_classes = zip(_classify_lines(lines), lines) @@ -294,7 +296,10 @@ def beautify(text, lang, options): # if mode is unknown, just don't transform the text at all return text + text = text.encode('utf-8') digest = "t:%s:%s:%s" % (hashlib.md5(text).hexdigest(), lang, mode) + # if lang == 'git': + # cache.delete(digest) answer = cache.get(digest) if answer: return answer