From 727f8099af9ace4a7a8e4489b34aa2db440336b2 Mon Sep 17 00:00:00 2001 From: Martin Basti Date: Fri, 12 Dec 2014 14:23:32 +0100 Subject: [PATCH] Fix traceback if zonemgr error contains unicode Ticket: https://fedorahosted.org/freeipa/ticket/4805 Reviewed-By: David Kupka --- ipaserver/install/bindinstance.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py index 547cf19ee..4e630e8dd 100644 --- a/ipaserver/install/bindinstance.py +++ b/ipaserver/install/bindinstance.py @@ -411,7 +411,14 @@ def zonemgr_callback(option, opt_str, value, parser): value = value.decode(encoding) validate_zonemgr_str(value) except ValueError, e: - parser.error("invalid zonemgr: " + unicode(e)) + # FIXME we can do this in better way + # https://fedorahosted.org/freeipa/ticket/4804 + # decode to proper stderr encoding + stderr_encoding = getattr(sys.stderr, 'encoding', None) + if stderr_encoding is None: + stderr_encoding = 'utf-8' + error = unicode(e).encode(stderr_encoding) + parser.error("invalid zonemgr: " + error) parser.values.zonemgr = value