[Python-3000-checkins] r65236 - in python/branches/py3k: Lib/test/test_zipfile.py Lib/zipfile.py Misc/NEWS

antoine.pitrou python-3000-checkins at python.org
Fri Jul 25 21:58:19 CEST 2008


Author: antoine.pitrou
Date: Fri Jul 25 21:58:18 2008
New Revision: 65236

Log:
Merged revisions 65235 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r65235 | antoine.pitrou | 2008-07-25 21:42:26 +0200 (ven., 25 juil. 2008) | 3 lines
  
  #3394: zipfile.writestr doesn't set external attributes, so files are extracted mode 000 on Unix
........


Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/Lib/test/test_zipfile.py
   python/branches/py3k/Lib/zipfile.py
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Lib/test/test_zipfile.py
==============================================================================
--- python/branches/py3k/Lib/test/test_zipfile.py	(original)
+++ python/branches/py3k/Lib/test/test_zipfile.py	Fri Jul 25 21:58:18 2008
@@ -365,6 +365,19 @@
         # remove the test file subdirectories
         shutil.rmtree(os.path.join(os.getcwd(), 'ziptest2dir'))
 
+    def zip_test_writestr_permissions(self, f, compression):
+        # Make sure that writestr creates files with mode 0600,
+        # when it is passed a name rather than a ZipInfo instance.
+
+        self.makeTestArchive(f, compression)
+        zipfp = zipfile.ZipFile(f, "r")
+        zinfo = zipfp.getinfo('strfile')
+        self.assertEqual(zinfo.external_attr, 0o600 << 16)
+
+    def test_writestr_permissions(self):
+        for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
+            self.zip_test_writestr_permissions(f, zipfile.ZIP_STORED)
+
     def tearDown(self):
         os.remove(TESTFN)
         os.remove(TESTFN2)

Modified: python/branches/py3k/Lib/zipfile.py
==============================================================================
--- python/branches/py3k/Lib/zipfile.py	(original)
+++ python/branches/py3k/Lib/zipfile.py	Fri Jul 25 21:58:18 2008
@@ -1075,6 +1075,7 @@
             zinfo = ZipInfo(filename=zinfo_or_arcname,
                             date_time=time.localtime(time.time())[:6])
             zinfo.compress_type = self.compression
+            zinfo.external_attr = 0o600 << 16
         else:
             zinfo = zinfo_or_arcname
 

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Fri Jul 25 21:58:18 2008
@@ -4,6 +4,19 @@
 
 (editors: check NEWS.help for information about editing NEWS using ReST.)
 
+What's new in Python 3.0b3?
+===========================
+
+*Release date: XX-XXX-2008*
+
+Library
+-------
+
+- Issue #3394: zipfile.writestr sets external attributes when passed a
+  file name rather than a ZipInfo instance, so files are extracted with
+  mode 0600 rather than 000 under Unix.
+
+
 What's new in Python 3.0b2?
 ===========================
 
@@ -191,7 +204,7 @@
 - The ``xmlrpc`` package was created; it contains the old
   ``xmlrpclib`` module as ``xmlrpc.client`` and the content of
   the old ``SimpleXMLRPCServer`` and ``DocXMLRPCServer`` modules
-  as ``xmlrpc.server``.  
+  as ``xmlrpc.server``.
 
 - The ``dbm`` package was created, containing the old modules
   ``anydbm`` and ``whichdb`` in its ``__init__.py``, and having
@@ -562,7 +575,7 @@
 - Fixed `imp.find_module()` to obey the -*- coding: -*- header.
 
 - Changed `__file__` and `co_filename` to unicode. The path names are decoded
-  with `Py_FileSystemDefaultEncoding` and a new API method 
+  with `Py_FileSystemDefaultEncoding` and a new API method
   `PyUnicode_DecodeFSDefault(char*)` was added.
 
 - io.open() and _fileio.FileIO have grown a new argument closefd. A


More information about the Python-3000-checkins mailing list