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
54edfb3e
Kaydet (Commit)
54edfb3e
authored
Eki 12, 2014
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #13664: GzipFile now supports non-ascii Unicode filenames.
üst
55bf20ad
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
3 deletions
+23
-3
gzip.py
Lib/gzip.py
+10
-3
test_gzip.py
Lib/test/test_gzip.py
+11
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/gzip.py
Dosyayı görüntüle @
54edfb3e
...
...
@@ -164,9 +164,16 @@ class GzipFile(io.BufferedIOBase):
def
_write_gzip_header
(
self
):
self
.
fileobj
.
write
(
'
\037\213
'
)
# magic header
self
.
fileobj
.
write
(
'
\010
'
)
# compression method
fname
=
os
.
path
.
basename
(
self
.
name
)
if
fname
.
endswith
(
".gz"
):
fname
=
fname
[:
-
3
]
try
:
# 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
)
if
not
isinstance
(
fname
,
str
):
fname
=
fname
.
encode
(
'latin-1'
)
if
fname
.
endswith
(
'.gz'
):
fname
=
fname
[:
-
3
]
except
UnicodeEncodeError
:
fname
=
''
flags
=
0
if
fname
:
flags
=
FNAME
...
...
Lib/test/test_gzip.py
Dosyayı görüntüle @
54edfb3e
...
...
@@ -30,6 +30,17 @@ class TestGzip(unittest.TestCase):
def
tearDown
(
self
):
test_support
.
unlink
(
self
.
filename
)
@test_support.requires_unicode
def
test_unicode_filename
(
self
):
unicode_filename
=
test_support
.
TESTFN_UNICODE
with
gzip
.
GzipFile
(
unicode_filename
,
"wb"
)
as
f
:
f
.
write
(
data1
*
50
)
with
gzip
.
GzipFile
(
unicode_filename
,
"rb"
)
as
f
:
self
.
assertEqual
(
f
.
read
(),
data1
*
50
)
# Sanity check that we are actually operating on the right file.
with
open
(
unicode_filename
,
'rb'
)
as
fobj
,
\
gzip
.
GzipFile
(
fileobj
=
fobj
,
mode
=
"rb"
)
as
f
:
self
.
assertEqual
(
f
.
read
(),
data1
*
50
)
def
test_write
(
self
):
with
gzip
.
GzipFile
(
self
.
filename
,
'wb'
)
as
f
:
...
...
Misc/NEWS
Dosyayı görüntüle @
54edfb3e
...
...
@@ -37,6 +37,8 @@ Core and Builtins
Library
-------
- Issue #13664: GzipFile now supports non-ascii Unicode filenames.
- Issue #13096: Fixed segfault in CTypes POINTER handling of large
values.
...
...
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