mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #13781: Fix GzipFile to work with os.fdopen()'d file objects.
This commit is contained in:
parent
031605ad99
commit
892b0b928d
3 changed files with 15 additions and 2 deletions
|
@ -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'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue