summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Gustäbel <lars@gustaebel.de>2010-04-29 15:35:30 (GMT)
committerLars Gustäbel <lars@gustaebel.de>2010-04-29 15:35:30 (GMT)
commitb4a5bc9313b8838fb69ddc809b50b62f9494d4a9 (patch)
treed7df276fd66368705e9d20ab07f92e6029e6c961
parentbb804c74a095efe20bc315f7ea83475d5b14a288 (diff)
downloadcpython-b4a5bc9313b8838fb69ddc809b50b62f9494d4a9.zip
cpython-b4a5bc9313b8838fb69ddc809b50b62f9494d4a9.tar.gz
cpython-b4a5bc9313b8838fb69ddc809b50b62f9494d4a9.tar.bz2
Merged revisions 80616 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r80616 | lars.gustaebel | 2010-04-29 17:23:38 +0200 (Thu, 29 Apr 2010) | 4 lines Issue #8464: tarfile.open(name, mode="w|") no longer creates files with execute permissions set. ........
-rw-r--r--Lib/tarfile.py2
-rw-r--r--Lib/test/test_tarfile.py18
-rw-r--r--Misc/NEWS3
3 files changed, 22 insertions, 1 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index 7643a0b..8c2d26b 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -370,7 +370,7 @@ class _LowLevelFile:
}[mode]
if hasattr(os, "O_BINARY"):
mode |= os.O_BINARY
- self.fd = os.open(name, mode)
+ self.fd = os.open(name, mode, 0666)
def close(self):
os.close(self.fd)
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index e2682c4..786f57a 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -703,6 +703,24 @@ class StreamWriteTest(WriteTestBase):
self.assert_(data.count("\0") == tarfile.RECORDSIZE,
"incorrect zero padding")
+ def test_file_mode(self):
+ # Test for issue #8464: Create files with correct
+ # permissions.
+ if sys.platform == "win32" or not hasattr(os, "umask"):
+ return
+
+ if os.path.exists(tmpname):
+ os.remove(tmpname)
+
+ original_umask = os.umask(0022)
+ try:
+ tar = tarfile.open(tmpname, self.mode)
+ tar.close()
+ mode = os.stat(tmpname).st_mode & 0777
+ self.assertEqual(mode, 0644, "wrong file permissions")
+ finally:
+ os.umask(original_umask)
+
class GNUWriteTest(unittest.TestCase):
# This testcase checks for correct creation of GNU Longname
diff --git a/Misc/NEWS b/Misc/NEWS
index af42470..16a4190 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -33,6 +33,9 @@ Core and Builtins
Library
-------
+- Issue #8464: tarfile no longer creates files with execute permissions set
+ when mode="w|" is used.
+
- Issue #7834: Fix connect() of Bluetooth L2CAP sockets with recent versions
of the Linux kernel. Patch by Yaniv Aknin.