Python 3: fix a bytes/str runtime issue

On python3, in grpc._links.service._Kernel._on_service_acceptance_event,
there is a runtime TypeError:

```
_on_service_acceptance_event
    group, method = service_acceptance.method.split('/')[1:3]
TypeError: 'str' does not support the buffer interface
```

It is fixed by using a bytes literal (`b'/'`) instead of a string literal.

This exposed another issue in grpc.beta._server where an exception was being
raised with a bytes literal for a message (a string should be used instead.)
pull/5916/head
Leifur Halldor Asgeirsson 9 years ago committed by Leif Halldor Asgeirsson
parent 39fd22193b
commit b9501bcb0b
  1. 4
      src/python/grpcio/grpc/_links/service.py
  2. 4
      src/python/grpcio/grpc/beta/_server.py

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc.
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -177,7 +177,7 @@ class _Kernel(object):
call = service_acceptance.call
call.accept(self._completion_queue, call)
try:
group, method = service_acceptance.method.split('/')[1:3]
group, method = service_acceptance.method.split(b'/')[1:3]
except ValueError:
logging.info('Illegal path "%s"!', service_acceptance.method)
return

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc.
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -62,7 +62,7 @@ class _GRPCServicer(base.Servicer):
if e.code is None and e.details is None:
raise base.NoSuchMethodError(
interfaces.StatusCode.UNIMPLEMENTED,
b'Method "%s" of service "%s" not implemented!' % (method, group))
'Method "%s" of service "%s" not implemented!' % (method, group))
else:
raise

Loading…
Cancel
Save