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
84f6de9d
Kaydet (Commit)
84f6de9d
authored
Şub 13, 2007
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Patch #1517891: Make 'a' create the file if it doesn't exist.
Fixes #1514451.
üst
c6d626ed
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
1 deletion
+38
-1
libzipfile.tex
Doc/lib/libzipfile.tex
+5
-0
test_zipfile.py
Lib/test/test_zipfile.py
+22
-0
zipfile.py
Lib/zipfile.py
+8
-1
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/lib/libzipfile.tex
Dosyayı görüntüle @
84f6de9d
...
...
@@ -101,6 +101,8 @@ cat myzip.zip >> python.exe
\end{verbatim}
also works, and at least
\program
{
WinZip
}
can read such files.
If
\var
{
mode
}
is
\code
{
a
}
and the file does not exist at all,
it is created.
\var
{
compression
}
is the ZIP compression method to use when writing
the archive, and should be
\constant
{
ZIP
_
STORED
}
or
\constant
{
ZIP
_
DEFLATED
}
; unrecognized values will cause
...
...
@@ -114,6 +116,9 @@ cat myzip.zip >> python.exe
ZIP file would require ZIP64 extensions. ZIP64 extensions are disabled by
default because the default
\program
{
zip
}
and
\program
{
unzip
}
commands on
\UNIX
{}
(the InfoZIP utilities) don't support these extensions.
\versionchanged
[If the file does not exist, it is created if the
mode is 'a']
{
2.6
}
\end{classdesc}
\begin{methoddesc}
{
close
}{}
...
...
Lib/test/test_zipfile.py
Dosyayı görüntüle @
84f6de9d
...
...
@@ -307,6 +307,28 @@ class PyZipFileTests(unittest.TestCase):
class
OtherTests
(
unittest
.
TestCase
):
def
testCreateNonExistentFileForAppend
(
self
):
if
os
.
path
.
exists
(
TESTFN
):
os
.
unlink
(
TESTFN
)
filename
=
'testfile.txt'
content
=
'hello, world. this is some content.'
try
:
zf
=
zipfile
.
ZipFile
(
TESTFN
,
'a'
)
zf
.
writestr
(
filename
,
content
)
zf
.
close
()
except
IOError
,
(
errno
,
errmsg
):
self
.
fail
(
'Could not append data to a non-existent zip file.'
)
self
.
assert_
(
os
.
path
.
exists
(
TESTFN
))
zf
=
zipfile
.
ZipFile
(
TESTFN
,
'r'
)
self
.
assertEqual
(
zf
.
read
(
filename
),
content
)
zf
.
close
()
os
.
unlink
(
TESTFN
)
def
testCloseErroneousFile
(
self
):
# This test checks that the ZipFile constructor closes the file object
# it opens if there's an error in the file. If it doesn't, the traceback
...
...
Lib/zipfile.py
Dosyayı görüntüle @
84f6de9d
...
...
@@ -396,7 +396,14 @@ class ZipFile:
self
.
_filePassed
=
0
self
.
filename
=
file
modeDict
=
{
'r'
:
'rb'
,
'w'
:
'wb'
,
'a'
:
'r+b'
}
self
.
fp
=
open
(
file
,
modeDict
[
mode
])
try
:
self
.
fp
=
open
(
file
,
modeDict
[
mode
])
except
IOError
:
if
mode
==
'a'
:
mode
=
key
=
'w'
self
.
fp
=
open
(
file
,
modeDict
[
mode
])
else
:
raise
else
:
self
.
_filePassed
=
1
self
.
fp
=
file
...
...
Misc/NEWS
Dosyayı görüntüle @
84f6de9d
...
...
@@ -128,6 +128,9 @@ Core and builtins
Library
-------
- Patch #1517891: Mode '
a
' for ZipFile now creates the file if it
doesn'
t
exist
.
-
Patch
#
698833
:
Support
file
decryption
in
zipfile
.
-
Patch
#
685268
:
Consider
a
package
's __path__ in imputil.
...
...
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