Patchwork [py3] setup: hide octal literals inside strings so they're portable (issue4554)

login
register
mail settings
Submitter Augie Fackler
Date May 5, 2015, 4:33 p.m.
Message ID <b6f858be11d6eeb8f9f3.1430843596@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/8896/
State Accepted
Headers show

Comments

Augie Fackler - May 5, 2015, 4:33 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1428867370 14400
#      Sun Apr 12 15:36:10 2015 -0400
# Node ID b6f858be11d6eeb8f9f3595773782f08e7fd1a46
# Parent  e5b507efb36e2b9ad8edb1a38459d26c934d74dd
setup: hide octal literals inside strings so they're portable (issue4554)
Matt Mackall - May 5, 2015, 5:44 p.m.
On Tue, 2015-05-05 at 12:33 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1428867370 14400
> #      Sun Apr 12 15:36:10 2015 -0400
> # Node ID b6f858be11d6eeb8f9f3595773782f08e7fd1a46
> # Parent  e5b507efb36e2b9ad8edb1a38459d26c934d74dd
> setup: hide octal literals inside strings so they're portable (issue4554)

This is awful. Queued for default, thanks.

Patch

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -408,11 +408,12 @@  class hginstalllib(install_lib):
                 # Persist executable bit (apply it to group and other if user
                 # has it)
                 if st[stat.ST_MODE] & stat.S_IXUSR:
-                    setmode = 0755
+                    setmode = int('0755', 8)
                 else:
-                    setmode = 0644
-                os.chmod(dst, (stat.S_IMODE(st[stat.ST_MODE]) & ~0777) |
-                         setmode)
+                    setmode = int('0644', 8)
+                m = stat.S_IMODE(st[stat.ST_MODE])
+                m = (m & ~int('0777', 8)) | setmode
+                os.chmod(dst, m)
         file_util.copy_file = copyfileandsetmode
         try:
             install_lib.run(self)