Quanlong Huang has uploaded this change for review. ( 
http://gerrit.cloudera.org:8080/17099


Change subject: IMPALA-10523: Fix impala-shell crash in printing error messages 
that contain UTF-8 characters
......................................................................

IMPALA-10523: Fix impala-shell crash in printing error messages that contain 
UTF-8 characters

In Python2, print() converts all non-keyword arguments to strings like
str() does and writes them to the stream. str() on QueryStateException
returns its value(i.e. error message) which could be in unicode type.
Python2 will implicitly encode it to str type using the default
encoding, ‘ascii’. This could result in UnicodeEncodeError when there
are non-ascii characters in the error message.

This patch explicitly encodes the error message using ‘utf-8’ encoding
if it’s in unicode type and the shell is run in Python2.

Tests:
 - Add test in test_shell_interactive.py

Change-Id: Ie10f5b03ecc5877053c2fbada1afaf256b423a71
---
M shell/impala_shell.py
M tests/shell/test_shell_interactive.py
2 files changed, 13 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/99/17099/1
--
To view, visit http://gerrit.cloudera.org:8080/17099
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie10f5b03ecc5877053c2fbada1afaf256b423a71
Gerrit-Change-Number: 17099
Gerrit-PatchSet: 1
Gerrit-Owner: Quanlong Huang <huangquanl...@gmail.com>

Reply via email to