From ba6e31eba192d6fcfc31d2f8ab2ad811a1322f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Fri, 12 Jul 2013 00:19:38 -0400 Subject: Don't crash when a file diff contains utf-8 chars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a crash when the client tries to render the diff of a file which includes unicode characters. This change assumes that utf-8 is the default encoding, which looking at the rest of the code appears to be a safe bet. Signed-off-by: Stéphane Graber --- src/lib/Bcfg2/Client/__init__.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/lib/Bcfg2') diff --git a/src/lib/Bcfg2/Client/__init__.py b/src/lib/Bcfg2/Client/__init__.py index 25603186e..6d1cb9d40 100644 --- a/src/lib/Bcfg2/Client/__init__.py +++ b/src/lib/Bcfg2/Client/__init__.py @@ -21,6 +21,9 @@ def prompt(msg): try: ans = input(msg) return ans in ['y', 'Y'] + except UnicodeEncodeError: + ans = input(msg.encode('utf-8')) + return ans in ['y', 'Y'] except EOFError: # handle ^C on rhel-based platforms raise SystemExit(1) -- cgit v1.2.3-1-g7c22