Issue #8464: tarfile.open(name, mode="w|") no longer creates
files with execute permissions set.
This commit is contained in:
parent
f56a288b1e
commit
5c4c4619b0
|
@ -380,7 +380,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)
|
||||
|
|
|
@ -847,6 +847,24 @@ class StreamWriteTest(WriteTestBase):
|
|||
self.assertTrue(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
|
||||
|
|
Loading…
Reference in New Issue