diff options
| author | Nadeem Vawda <nadeem.vawda@gmail.com> | 2012-01-18 22:40:46 (GMT) |
|---|---|---|
| committer | Nadeem Vawda <nadeem.vawda@gmail.com> | 2012-01-18 22:40:46 (GMT) |
| commit | d7664dee0c35c01e71fc0ea65d0b7547dfb0212a (patch) | |
| tree | b2e677ee3580ab47d9379de12b97603c09c3ec49 /Lib/gzip.py | |
| parent | e09bc1e8f54620e938b7e076830b872a8daabd2c (diff) | |
| download | cpython-d7664dee0c35c01e71fc0ea65d0b7547dfb0212a.zip cpython-d7664dee0c35c01e71fc0ea65d0b7547dfb0212a.tar.gz cpython-d7664dee0c35c01e71fc0ea65d0b7547dfb0212a.tar.bz2 | |
Issue #13781: Fix GzipFile to work with os.fdopen()'d file objects.
Diffstat (limited to 'Lib/gzip.py')
| -rw-r--r-- | Lib/gzip.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/gzip.py b/Lib/gzip.py index 2bcb4db..8fdac83 100644 --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -88,8 +88,12 @@ class GzipFile(io.BufferedIOBase): if fileobj is None: fileobj = self.myfileobj = __builtin__.open(filename, mode or 'rb') if filename is None: - if hasattr(fileobj, 'name'): filename = fileobj.name - else: filename = '' + # Issue #13781: os.fdopen() creates a fileobj with a bogus name + # attribute. Avoid saving this in the gzip header's filename field. + if hasattr(fileobj, 'name') and fileobj.name != '<fdopen>': + filename = fileobj.name + else: + filename = '' if mode is None: if hasattr(fileobj, 'mode'): mode = fileobj.mode else: mode = 'rb' |
