diff options
author | Lidi Zheng <lidiz@google.com> | 2018-11-05 13:31:02 -0800 |
---|---|---|
committer | Lidi Zheng <lidiz@google.com> | 2018-11-05 13:31:02 -0800 |
commit | b8a99890050087d417cbcd2c86feac9b801d57d4 (patch) | |
tree | 7564717821fce2a02ad70b8670fe2ea6a294eb10 /src/python/grpcio | |
parent | e4faafa5eb2b0b877a4b15822fb40101eea28a73 (diff) |
Add support for utf-8 error messages
* Both server and client should be fine with utf-8 error messages now
* Adding an interop test: special status message
Diffstat (limited to 'src/python/grpcio')
-rw-r--r-- | src/python/grpcio/grpc/_common.py | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/python/grpcio/grpc/_common.py b/src/python/grpcio/grpc/_common.py index d35f4566bd..42f3a4e614 100644 --- a/src/python/grpcio/grpc/_common.py +++ b/src/python/grpcio/grpc/_common.py @@ -66,18 +66,13 @@ def encode(s): if isinstance(s, bytes): return s else: - return s.encode('ascii') + return s.encode('utf8') def decode(b): - if isinstance(b, str): - return b - else: - try: - return b.decode('utf8') - except UnicodeDecodeError: - _LOGGER.exception('Invalid encoding on %s', b) - return b.decode('latin1') + if isinstance(b, bytes): + return b.decode('utf-8', 'replace') + return b def _transform(message, transformer, exception_message): |