Skip to content

Commit

Permalink
Bug 1293234 - Use octal notation for permission modes in the build sy…
Browse files Browse the repository at this point in the history
…stem; r=gps

As of Python 3, decimal notations of octal values for permission modes
are no longer permitted and will result in a `SyntaxError` exception
(`invalid token`).

Using the proper octal notation which is also Python 2.7 compatible will
fix this issue.

--HG--
extra : rebase_source : 2e897c51f04ad0ee69071f84b98df224f3af72d3
  • Loading branch information
eliasp committed Aug 8, 2016
1 parent ea762ca commit fa561f2
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion config/nsinstall.py
Expand Up @@ -41,7 +41,7 @@ def _nsinstall_internal(argv):
# implented.
def BadArg(option, opt, value, parser):
parser.error('option not supported: {0}'.format(opt))

p.add_option('-C', action="callback", metavar="CWD",
callback=BadArg,
help="NOT SUPPORTED")
Expand Down
2 changes: 1 addition & 1 deletion config/tests/unit-nsinstall.py
Expand Up @@ -119,7 +119,7 @@ def test_nsinstall_t(self):
def test_nsinstall_m(self):
"Test that nsinstall -m works (set mode)"
testfile = self.touch("testfile")
mode = 0600
mode = 0o600
os.chmod(testfile, mode)
testdir = self.mkdirs("testdir")
self.assertEqual(nsinstall(["-m", "{0:04o}"
Expand Down
2 changes: 1 addition & 1 deletion configure.py
Expand Up @@ -81,7 +81,7 @@ def sanitized_bools(v):

# Other things than us are going to run this file, so we need to give it
# executable permissions.
os.chmod('config.status', 0755)
os.chmod('config.status', 0o755)
if config.get('MOZ_BUILD_APP') != 'js' or config.get('JS_STANDALONE'):
os.environ['WRITE_MOZINFO'] = '1'
# Until we have access to the virtualenv from this script, execute
Expand Down
8 changes: 4 additions & 4 deletions python/mozbuild/mozpack/copier.py
Expand Up @@ -324,9 +324,9 @@ def copy(self, destination, skip_if_older=True,
os.mkdir(d)

if not os.access(d, os.W_OK):
umask = os.umask(0077)
umask = os.umask(0o077)
os.umask(umask)
os.chmod(d, 0777 & ~umask)
os.chmod(d, 0o777 & ~umask)

if isinstance(remove_unaccounted, FileRegistry):
existing_files = set(os.path.normpath(os.path.join(destination, p))
Expand Down Expand Up @@ -412,7 +412,7 @@ def copy(self, destination, skip_if_older=True,
if os.name == 'nt' and not os.access(f, os.W_OK):
# It doesn't matter what we set permissions to since we
# will remove this file shortly.
os.chmod(f, 0600)
os.chmod(f, 0o600)

os.remove(f)
result.removed_files.add(f)
Expand Down Expand Up @@ -454,7 +454,7 @@ def copy(self, destination, skip_if_older=True,
if e.errno in (errno.EPERM, errno.EACCES):
# Permissions may not allow deletion. So ensure write
# access is in place before attempting to rmdir again.
os.chmod(d, 0700)
os.chmod(d, 0o700)
os.rmdir(d)
else:
raise
Expand Down
4 changes: 2 additions & 2 deletions python/mozbuild/mozpack/test/test_copier.py
Expand Up @@ -337,8 +337,8 @@ def test_permissions(self):
# Make file and directory unwritable. Reminder: making a directory
# unwritable prevents modifications (including deletes) from the list
# of files in that directory.
os.chmod(p, 0400)
os.chmod(self.tmpdir, 0400)
os.chmod(p, 0o400)
os.chmod(self.tmpdir, 0o400)

copier = FileCopier()
copier.add('dummy', GeneratedFile('content'))
Expand Down

0 comments on commit fa561f2

Please sign in to comment.