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 02afcab commit 2b2421aCopy full SHA for 2b2421a
src/hpack/hpack.py
@@ -147,10 +147,13 @@ def _to_bytes(string):
147
"""
148
Convert string to bytes.
149
150
- if not isinstance(string, basestring): # pragma: no cover
151
- string = str(string)
+ if isinstance(string, bytes):
+ return string
152
153
- return string if isinstance(string, bytes) else string.encode('utf-8')
+ # Not doing an `isinstance(string, basestring)` check here
154
+ # as the cost of it is the same as just running `str()` on
155
+ # an object that is already a string
156
+ return str(string).encode("utf-8")
157
158
159
class Encoder:
0 commit comments