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
103e8113
Kaydet (Commit)
103e8113
authored
Haz 19, 2012
tarafından
Nadeem Vawda
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix GzipFile's handling of filenames given as bytes objects.
üst
f29ec4b0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
4 deletions
+20
-4
gzip.py
Lib/gzip.py
+4
-4
test_gzip.py
Lib/test/test_gzip.py
+14
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/gzip.py
Dosyayı görüntüle @
103e8113
...
...
@@ -159,9 +159,8 @@ 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'
)
and
isinstance
(
fileobj
.
name
,
str
):
filename
=
fileobj
.
name
else
:
filename
=
getattr
(
fileobj
,
'name'
,
''
)
if
not
isinstance
(
filename
,
(
str
,
bytes
)):
filename
=
''
if
mode
is
None
:
if
hasattr
(
fileobj
,
'mode'
):
mode
=
fileobj
.
mode
...
...
@@ -236,7 +235,8 @@ class GzipFile(io.BufferedIOBase):
# RFC 1952 requires the FNAME field to be Latin-1. Do not
# include filenames that cannot be represented that way.
fname
=
os
.
path
.
basename
(
self
.
name
)
fname
=
fname
.
encode
(
'latin-1'
)
if
not
isinstance
(
fname
,
bytes
):
fname
=
fname
.
encode
(
'latin-1'
)
if
fname
.
endswith
(
b
'.gz'
):
fname
=
fname
[:
-
3
]
except
UnicodeEncodeError
:
...
...
Lib/test/test_gzip.py
Dosyayı görüntüle @
103e8113
...
...
@@ -331,6 +331,20 @@ class TestGzip(unittest.TestCase):
with
gzip
.
GzipFile
(
fileobj
=
f
,
mode
=
"w"
)
as
g
:
pass
def
test_bytes_filename
(
self
):
str_filename
=
self
.
filename
try
:
bytes_filename
=
str_filename
.
encode
(
"ascii"
)
except
UnicodeEncodeError
:
self
.
skipTest
(
"Temporary file name needs to be ASCII"
)
with
gzip
.
GzipFile
(
bytes_filename
,
"wb"
)
as
f
:
f
.
write
(
data1
*
50
)
with
gzip
.
GzipFile
(
bytes_filename
,
"rb"
)
as
f
:
self
.
assertEqual
(
f
.
read
(),
data1
*
50
)
# Sanity check that we are actually operating on the right file.
with
gzip
.
GzipFile
(
str_filename
,
"rb"
)
as
f
:
self
.
assertEqual
(
f
.
read
(),
data1
*
50
)
# Testing compress/decompress shortcut functions
def
test_compress
(
self
):
...
...
Misc/NEWS
Dosyayı görüntüle @
103e8113
...
...
@@ -70,6 +70,8 @@ Core and Builtins
Library
-------
- Fix GzipFile's handling of filenames given as bytes objects.
- Issue #15101: Make pool finalizer avoid joining current thread.
- Issue #15036: Mailbox no longer throws an error if a flush is done
...
...
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