MCPcopy Index your code
hub / github.com/python/cpython / gzip_decode

Function gzip_decode

Lib/xmlrpc/client.py:1039–1056  ·  view source on GitHub ↗

gzip encoded data -> unencoded data Decode data using the gzip content encoding as described in RFC 1952

(data, max_decode=20971520)

Source from the content-addressed store, hash-verified

1037# @raises ValueError if max gzipped payload length exceeded
1038
1039def gzip_decode(data, max_decode=20971520):
1040 """gzip encoded data -> unencoded data
1041
1042 Decode data using the gzip content encoding as described in RFC 1952
1043 """
1044 if not gzip:
1045 raise NotImplementedError
1046 with gzip.GzipFile(mode="rb", fileobj=BytesIO(data)) as gzf:
1047 try:
1048 if max_decode < 0: # no limit
1049 decoded = gzf.read()
1050 else:
1051 decoded = gzf.read(max_decode + 1)
1052 except OSError:
1053 raise ValueError("invalid data")
1054 if max_decode >= 0 and len(decoded) > max_decode:
1055 raise ValueError("max gzipped payload length exceeded")
1056 return decoded
1057
1058##
1059# Return a decoded file-like object for the gzip encoding

Callers 1

Calls 2

BytesIOClass · 0.90
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…