Skip to content

Commit

Permalink
Avoid hasattr in BrotliDecoder.decompress()
Browse files Browse the repository at this point in the history
  • Loading branch information
auscompgeek committed Apr 19, 2020
1 parent 1f0825b commit 8fadde1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/urllib3/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,10 @@ class BrotliDecoder(object):
# are for 'brotlipy' and bottom branches for 'Brotli'
def __init__(self):
self._obj = brotli.Decompressor()

def decompress(self, data):
if hasattr(self._obj, "decompress"):
return self._obj.decompress(data)
return self._obj.process(data)
self.decompress = self._obj.decompress
else:
self.decompress = self._obj.process

def flush(self):
if hasattr(self._obj, "flush"):
Expand Down

0 comments on commit 8fadde1

Please sign in to comment.