From b5262c850ed6f918a1ed9154ff9a4ce915b30999 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 21 Aug 2016 21:48:21 +0200 Subject: [PATCH] Exit cleanly in case of non UTF-8 file. --- cdist/config.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cdist/config.py b/cdist/config.py index 2f28a22f..e20f1a7c 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -121,9 +121,10 @@ class Config(object): host = Config.hostfile_process_line(host) if host: yield host - except (IOError, OSError) as e: - raise cdist.Error("Error reading hosts from \'{}\'".format( - source)) + except (IOError, OSError, UnicodeError) as e: + raise cdist.Error( + "Error reading hosts from file \'{}\': {}".format( + source, e)) else: if source: for host in source: