We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
bytes
1 parent f5cf6b9 commit e574f0dCopy full SHA for e574f0d
src/hpack/hpack.py
@@ -143,14 +143,16 @@ def _dict_to_iterable(header_dict):
143
yield key, header_dict[key]
144
145
146
-def _to_bytes(string):
+def _to_bytes(value):
147
"""
148
- Convert string to bytes.
+ Convert anything to bytes through a UTF-8 encoded string
149
150
- if not isinstance(string, basestring): # pragma: no cover
151
- string = str(string)
152
-
153
- return string if isinstance(string, bytes) else string.encode('utf-8')
+ t = type(value)
+ if t is bytes:
+ return value
+ if t is not str:
154
+ value = str(value)
155
+ return value.encode("utf-8")
156
157
158
class Encoder:
0 commit comments