Skip to content
This repository was archived by the owner on Jul 11, 2022. It is now read-only.

Commit ad2bfa7

Browse files
committed
[py3] fix TypeError: a bytes-like object is required, not 'str'
Use `six.PY3` to force non-unicode strings in Python 2.
1 parent aa2bdab commit ad2bfa7

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

jaeger_client/constants.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
from . import __version__
2424

25+
import six
2526

2627
# Max number of bits to use when generating random ID
2728
MAX_ID_BITS = 64
@@ -33,10 +34,10 @@
3334
DEFAULT_FLUSH_INTERVAL = 1
3435

3536
# Name of the HTTP header used to encode trace ID
36-
TRACE_ID_HEADER = b'uber-trace-id'
37+
TRACE_ID_HEADER = 'uber-trace-id' if six.PY3 else b'uber-trace-id'
3738

3839
# Prefix for HTTP headers used to record baggage items
39-
BAGGAGE_HEADER_PREFIX = b'uberctx-'
40+
BAGGAGE_HEADER_PREFIX = 'uberctx-' if six.PY3 else b'uberctx-'
4041

4142
# The name of HTTP header or a TextMap carrier key which, if found in the
4243
# carrier, forces the trace to be sampled as "debug" trace. The value of the

tests/test_TUDPTransport.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_constructor_nonblocking(self):
3939
assert t.transport_sock.gettimeout() == 0
4040

4141
def test_write(self):
42-
self.t.write('hello')
42+
self.t.write(b'hello')
4343

4444
def test_isopen_when_open(self):
4545
assert self.t.isOpen() == True
@@ -52,4 +52,4 @@ def test_close(self):
5252
self.t.close()
5353
with self.assertRaises(Exception):
5454
# Something bad should happen if we send on a closed socket..
55-
self.t.write('hello')
55+
self.t.write(b'hello')

0 commit comments

Comments
 (0)