[2.7] bpo-33038: gzip.GzipFile assumes non-None name attribute by bbayles · Pull Request #6095 · python/cpython

In Python 2.7 gzip.GzipFile does hasattr(fileobj, 'name') to see if fileobj has a .name attribute, but then assumes that attribute is not None.

This isn't always a good assumption - for example, tempfile.SpooledTemporaryFile defines .name, but it can be None:
https://github.com/python/cpython/blob/2.7/Lib/tempfile.py#L597

Python 3's GzipFile doesn't have this issue, thankfully.

https://bugs.python.org/issue33038