FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: Support urllib3 >= 2.6.0 by chandra-siri · Pull Request #1658 · googleapis/python-storage · GitHub

This repository was archived by the owner on Mar 31, 2026. It is now read-only.
/ python-storage Public archive
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension .py  (1) .txt  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
21 changes: 17 additions & 4 deletions google/cloud/storage/_media/requests/download.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ def __init__(self, checksum):
super().__init__()
self._checksum = checksum

def decompress(self, data):
def decompress(self, data, max_length=-1):
"""Decompress the bytes.

Args:
Expand All @@ -721,7 +721,11 @@ def decompress(self, data):
bytes: The decompressed bytes from ``data``.
"""
self._checksum.update(data)
return super().decompress(data)
try:
return super().decompress(data, max_length=max_length)
except TypeError:
# Fallback for urllib3 < 2.6.0 which lacks `max_length` support.
return super().decompress(data)
Comment thread
chandra-siri marked this conversation as resolved.


# urllib3.response.BrotliDecoder might not exist depending on whether brotli is
Expand All @@ -747,7 +751,7 @@ def __init__(self, checksum):
self._decoder = urllib3.response.BrotliDecoder()
self._checksum = checksum

def decompress(self, data):
def decompress(self, data, max_length=-1):
"""Decompress the bytes.

Args:
Expand All @@ -757,10 +761,19 @@ def decompress(self, data):
bytes: The decompressed bytes from ``data``.
"""
self._checksum.update(data)
return self._decoder.decompress(data)
try:
return self._decoder.decompress(data, max_length=max_length)
except TypeError:
# Fallback for urllib3 < 2.6.0 which lacks `max_length` support.
return self._decoder.decompress(data)
Comment thread
chandra-siri marked this conversation as resolved.

def flush(self):
return self._decoder.flush()

@property
def has_unconsumed_tail(self) -> bool:
return self._decoder.has_unconsumed_tail
Comment thread
chandra-siri marked this conversation as resolved.


else: # pragma: NO COVER
_BrotliDecoder = None # type: ignore # pragma: NO COVER
1 change: 0 additions & 1 deletion testing/constraints-3.12.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ grpcio
proto-plus
protobuf
grpc-google-iam-v1
urllib3==2.5.0
Comment thread
chandra-siri marked this conversation as resolved.

Back | FazBrowse Home | New Git URL