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.
1 parent 2b2421a commit 10a3faeCopy full SHA for 10a3fae
src/hpack/hpack.py
@@ -147,13 +147,12 @@ def _to_bytes(string):
147
"""
148
Convert string to bytes.
149
150
- if isinstance(string, bytes):
+ t = type(string)
151
+ if t is bytes:
152
return string
-
153
- # 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")
+ if t is not str:
+ string = str(string)
+ return string.encode("utf-8")
157
158
159
class Encoder:
0 commit comments