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
85825dc1
Kaydet (Commit)
85825dc1
authored
Agu 27, 2007
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Changes preparing for stricter enforcement of bytes vs. str.
üst
56e4a840
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
11 deletions
+15
-11
test_zipimport.py
Lib/test/test_zipimport.py
+1
-1
zipfile.py
Lib/zipfile.py
+14
-10
No files found.
Lib/test/test_zipimport.py
Dosyayı görüntüle @
85825dc1
...
...
@@ -255,7 +255,7 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
# stuff at the beginning of the file
files
=
{
TESTMOD
+
".py"
:
(
NOW
,
test_src
)}
self
.
doTest
(
".py"
,
files
,
TESTMOD
,
stuff
=
"Some Stuff"
*
31
)
stuff
=
b
"Some Stuff"
*
31
)
def
assertModuleSource
(
self
,
module
):
self
.
assertEqual
(
inspect
.
getsource
(
module
),
test_src
)
...
...
Lib/zipfile.py
Dosyayı görüntüle @
85825dc1
...
...
@@ -909,10 +909,14 @@ class ZipFile:
self
.
filelist
.
append
(
zinfo
)
self
.
NameToInfo
[
zinfo
.
filename
]
=
zinfo
def
writestr
(
self
,
zinfo_or_arcname
,
bytes
):
"""Write a file into the archive. The contents is the string
'bytes'. 'zinfo_or_arcname' is either a ZipInfo instance or
def
writestr
(
self
,
zinfo_or_arcname
,
data
):
"""Write a file into the archive. The contents is 'data', which
may be either a 'str' or a 'bytes' instance; if it is a 'str',
it is encoded as UTF-8 first.
'zinfo_or_arcname' is either a ZipInfo instance or
the name of the file in the archive."""
if
isinstance
(
data
,
str
):
data
=
data
.
encode
(
"utf-8"
)
if
not
isinstance
(
zinfo_or_arcname
,
ZipInfo
):
zinfo
=
ZipInfo
(
filename
=
zinfo_or_arcname
,
date_time
=
time
.
localtime
(
time
.
time
()))
...
...
@@ -924,21 +928,21 @@ class ZipFile:
raise
RuntimeError
(
"Attempt to write to ZIP archive that was already closed"
)
zinfo
.
file_size
=
len
(
bytes
)
# Uncompressed size
zinfo
.
header_offset
=
self
.
fp
.
tell
()
# Start of header
bytes
zinfo
.
file_size
=
len
(
data
)
# Uncompressed size
zinfo
.
header_offset
=
self
.
fp
.
tell
()
# Start of header
data
self
.
_writecheck
(
zinfo
)
self
.
_didModify
=
True
zinfo
.
CRC
=
binascii
.
crc32
(
bytes
)
# CRC-32 checksum
zinfo
.
CRC
=
binascii
.
crc32
(
data
)
# CRC-32 checksum
if
zinfo
.
compress_type
==
ZIP_DEFLATED
:
co
=
zlib
.
compressobj
(
zlib
.
Z_DEFAULT_COMPRESSION
,
zlib
.
DEFLATED
,
-
15
)
bytes
=
co
.
compress
(
bytes
)
+
co
.
flush
()
zinfo
.
compress_size
=
len
(
bytes
)
# Compressed size
data
=
co
.
compress
(
data
)
+
co
.
flush
()
zinfo
.
compress_size
=
len
(
data
)
# Compressed size
else
:
zinfo
.
compress_size
=
zinfo
.
file_size
zinfo
.
header_offset
=
self
.
fp
.
tell
()
# Start of header
bytes
zinfo
.
header_offset
=
self
.
fp
.
tell
()
# Start of header
data
self
.
fp
.
write
(
zinfo
.
FileHeader
())
self
.
fp
.
write
(
bytes
)
self
.
fp
.
write
(
data
)
self
.
fp
.
flush
()
if
zinfo
.
flag_bits
&
0x08
:
# Write CRC and file sizes after the file data
...
...
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