Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
d7664dee
Kaydet (Commit)
d7664dee
authored
Ock 18, 2012
tarafından
Nadeem Vawda
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #13781: Fix GzipFile to work with os.fdopen()'d file objects.
üst
e09bc1e8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
2 deletions
+19
-2
gzip.py
Lib/gzip.py
+6
-2
test_gzip.py
Lib/test/test_gzip.py
+8
-0
NEWS
Misc/NEWS
+3
-0
posixmodule.c
Modules/posixmodule.c
+2
-0
No files found.
Lib/gzip.py
Dosyayı görüntüle @
d7664dee
...
@@ -88,8 +88,12 @@ class GzipFile(io.BufferedIOBase):
...
@@ -88,8 +88,12 @@ class GzipFile(io.BufferedIOBase):
if
fileobj
is
None
:
if
fileobj
is
None
:
fileobj
=
self
.
myfileobj
=
__builtin__
.
open
(
filename
,
mode
or
'rb'
)
fileobj
=
self
.
myfileobj
=
__builtin__
.
open
(
filename
,
mode
or
'rb'
)
if
filename
is
None
:
if
filename
is
None
:
if
hasattr
(
fileobj
,
'name'
):
filename
=
fileobj
.
name
# Issue #13781: os.fdopen() creates a fileobj with a bogus name
else
:
filename
=
''
# 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
mode
is
None
:
if
hasattr
(
fileobj
,
'mode'
):
mode
=
fileobj
.
mode
if
hasattr
(
fileobj
,
'mode'
):
mode
=
fileobj
.
mode
else
:
mode
=
'rb'
else
:
mode
=
'rb'
...
...
Lib/test/test_gzip.py
Dosyayı görüntüle @
d7664dee
...
@@ -274,6 +274,14 @@ class TestGzip(unittest.TestCase):
...
@@ -274,6 +274,14 @@ class TestGzip(unittest.TestCase):
d
=
f
.
read
()
d
=
f
.
read
()
self
.
assertEqual
(
d
,
data1
*
50
,
"Incorrect data in file"
)
self
.
assertEqual
(
d
,
data1
*
50
,
"Incorrect data in file"
)
def
test_fileobj_from_fdopen
(
self
):
# Issue #13781: Creating a GzipFile using a fileobj from os.fdopen()
# should not embed the fake filename "<fdopen>" in the output file.
fd
=
os
.
open
(
self
.
filename
,
os
.
O_WRONLY
|
os
.
O_CREAT
)
with
os
.
fdopen
(
fd
,
"wb"
)
as
f
:
with
gzip
.
GzipFile
(
fileobj
=
f
,
mode
=
"w"
)
as
g
:
self
.
assertEqual
(
g
.
name
,
""
)
def
test_main
(
verbose
=
None
):
def
test_main
(
verbose
=
None
):
test_support
.
run_unittest
(
TestGzip
)
test_support
.
run_unittest
(
TestGzip
)
...
...
Misc/NEWS
Dosyayı görüntüle @
d7664dee
...
@@ -89,6 +89,9 @@ Core and Builtins
...
@@ -89,6 +89,9 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
13781
:
Prevent
gzip
.
GzipFile
from
using
the
dummy
filename
provided
by
file
objects
opened
with
os
.
fdopen
().
-
Issue
#
13589
:
Fix
some
serialization
primitives
in
the
aifc
module
.
-
Issue
#
13589
:
Fix
some
serialization
primitives
in
the
aifc
module
.
Patch
by
Oleg
Plakhotnyuk
.
Patch
by
Oleg
Plakhotnyuk
.
...
...
Modules/posixmodule.c
Dosyayı görüntüle @
d7664dee
...
@@ -6755,6 +6755,8 @@ posix_fdopen(PyObject *self, PyObject *args)
...
@@ -6755,6 +6755,8 @@ posix_fdopen(PyObject *self, PyObject *args)
PyMem_FREE
(
mode
);
PyMem_FREE
(
mode
);
if
(
fp
==
NULL
)
if
(
fp
==
NULL
)
return
posix_error
();
return
posix_error
();
/* The dummy filename used here must be kept in sync with the value
tested against in gzip.GzipFile.__init__() - see issue #13781. */
f
=
PyFile_FromFile
(
fp
,
"<fdopen>"
,
orgmode
,
fclose
);
f
=
PyFile_FromFile
(
fp
,
"<fdopen>"
,
orgmode
,
fclose
);
if
(
f
!=
NULL
)
if
(
f
!=
NULL
)
PyFile_SetBufSize
(
f
,
bufsize
);
PyFile_SetBufSize
(
f
,
bufsize
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment