diff options
author | Nadeem Vawda <nadeem.vawda@gmail.com> | 2012-01-18 09:25:58 +0200 |
---|---|---|
committer | Nadeem Vawda <nadeem.vawda@gmail.com> | 2012-01-18 09:25:58 +0200 |
commit | 892b0b928df40da72b0d88c5e1a2c879eff543c4 (patch) | |
tree | 7cf5d742852255285657770cc20baaa80baf1db8 /Lib/gzip.py | |
parent | 031605ad999fa33e6da3eae3791c368826bd8311 (diff) | |
download | cpython-git-892b0b928df40da72b0d88c5e1a2c879eff543c4.tar.gz |
Issue #13781: Fix GzipFile to work with os.fdopen()'d file objects.
Diffstat (limited to 'Lib/gzip.py')
-rw-r--r-- | Lib/gzip.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/gzip.py b/Lib/gzip.py index ba2149ebf9..4462187116 100644 --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -156,8 +156,10 @@ class GzipFile(io.BufferedIOBase): if fileobj is None: fileobj = self.myfileobj = builtins.open(filename, mode or 'rb') if filename is None: - if hasattr(fileobj, 'name'): filename = fileobj.name - else: filename = '' + if hasattr(fileobj, 'name') and isinstance(fileobj.name, str): + filename = fileobj.name + else: + filename = '' if mode is None: if hasattr(fileobj, 'mode'): mode = fileobj.mode else: mode = 'rb' |