From 7a8b27f716ab98400175e13bdc767e728ad2d558 Mon Sep 17 00:00:00 2001 From: Rune Kaagaard Date: Tue, 5 Feb 2013 14:49:59 +0100 Subject: [PATCH] Fixing bug with unicode templates. The utils.md5s() function would break when calculating checksums for non-ascii characters. Convert to utf-8 first. --- lib/ansible/utils/__init__.py | 2 +- test/sample.j2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/utils/__init__.py b/lib/ansible/utils/__init__.py index 891446d7667..4c640946aa5 100644 --- a/lib/ansible/utils/__init__.py +++ b/lib/ansible/utils/__init__.py @@ -301,7 +301,7 @@ def md5s(data): ''' Return MD5 hex digest of data. ''' digest = _md5() - digest.update(data) + digest.update(data.encode('utf-8')) return digest.hexdigest() def md5(filename): diff --git a/test/sample.j2 b/test/sample.j2 index cd0c8819e85..d33e9105494 100644 --- a/test/sample.j2 +++ b/test/sample.j2 @@ -1,4 +1,4 @@ -Are you pondering what I'm pondering? +Are you pondering what I'm pøndering? I think so Brain, but {{ answer }}