summaryrefslogtreecommitdiffstats
path: root/Lib/gzip.py
diff options
context:
space:
mode:
authorNadeem Vawda <nadeem.vawda@gmail.com>2012-01-18 07:32:25 (GMT)
committerNadeem Vawda <nadeem.vawda@gmail.com>2012-01-18 07:32:25 (GMT)
commit50a4d5debb952bb319d8a8141e47a39c3fb03250 (patch)
tree6d841af85219705d274635be1dba15dc9bb85b31 /Lib/gzip.py
parent5c1d814e6fc3fc154db288cab557106e72a53506 (diff)
parent892b0b928df40da72b0d88c5e1a2c879eff543c4 (diff)
downloadcpython-50a4d5debb952bb319d8a8141e47a39c3fb03250.zip
cpython-50a4d5debb952bb319d8a8141e47a39c3fb03250.tar.gz
cpython-50a4d5debb952bb319d8a8141e47a39c3fb03250.tar.bz2
Merge: #13781: Fix GzipFile to work with os.fdopen()'d file objects.
Diffstat (limited to 'Lib/gzip.py')
-rw-r--r--Lib/gzip.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/gzip.py b/Lib/gzip.py
index e6b8193..93dda4e 100644
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -144,8 +144,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'