From 74dceaee0e5d380671e6478350e81108fd43e126 Mon Sep 17 00:00:00 2001 From: chenxiao Date: Thu, 26 Sep 2013 22:58:12 +0800 Subject: [PATCH] Fixes print error for keystone action with non-English characters When processing keystone tenant-delete action with non-English characters, printing the exception traceback will result in a UnicodeEncodeError, so should encode text with safe_encode. Fixes bug #1231472 Change-Id: Ic2599c51513189c132e31aa87d0d15df81802688 --- keystoneclient/shell.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/keystoneclient/shell.py b/keystoneclient/shell.py index 1c3427370..b530afda4 100644 --- a/keystoneclient/shell.py +++ b/keystoneclient/shell.py @@ -27,6 +27,7 @@ from __future__ import print_function import argparse import getpass import os +import six import sys import keystoneclient @@ -35,6 +36,7 @@ from keystoneclient import access from keystoneclient.contrib.bootstrap import shell as shell_bootstrap from keystoneclient import exceptions as exc from keystoneclient.generic import shell as shell_generic +from keystoneclient.openstack.common import strutils from keystoneclient import utils from keystoneclient.v2_0 import shell as shell_v2_0 @@ -488,7 +490,7 @@ def main(): OpenStackIdentityShell().main(sys.argv[1:]) except Exception as e: - print(e, file=sys.stderr) + print(strutils.safe_encode(six.text_type(e)), file=sys.stderr) sys.exit(1)