[pacman-dev] [PATCH 3/8] Python 3 octal literals broke backwards compatibility.

Jeremy Heiner scalaprotractor at gmail.com
Wed Oct 9 20:35:06 EDT 2013


Reported by 2to3. The suggested fix (use the 0o# format) won't work
here because that syntax is not recognized by 2.5.

Signed-off-by: Jeremy Heiner <ScalaProtractor at gmail.com>

Conflicts:
	test/pacman/pmpkg.py
---
 test/pacman/pmpkg.py  |  4 ++--
 test/pacman/pmtest.py |  2 +-
 test/pacman/util.py   | 10 +++++++---
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/test/pacman/pmpkg.py b/test/pacman/pmpkg.py
index c60f11b..0c1ea68 100644
--- a/test/pacman/pmpkg.py
+++ b/test/pacman/pmpkg.py
@@ -161,9 +161,9 @@ def makepkg(self, path):
             if fileinfo["hasperms"]:
                 info.mode = fileinfo["perms"]
             elif fileinfo["isdir"]:
-                info.mode = 0755
+                info.mode = util.PERM_DIR
             elif not fileinfo["islink"]:
-                info.mode = 0644
+                info.mode = util.PERM_FILE
             if fileinfo["isdir"]:
                 info.type = tarfile.DIRTYPE
                 tar.addfile(info)
diff --git a/test/pacman/pmtest.py b/test/pacman/pmtest.py
index c183161..57e6538 100644
--- a/test/pacman/pmtest.py
+++ b/test/pacman/pmtest.py
@@ -134,7 +134,7 @@ def generate(self, pacman):
         for sys_dir in sys_dirs:
             if not os.path.isdir(sys_dir):
                 vprint("\t%s" % sys_dir[len(self.root)+1:])
-                os.makedirs(sys_dir, 0755)
+                os.makedirs(sys_dir, util.PERM_DIR)
         # Only the dynamically linked binary is needed for fakechroot
         shutil.copy("/bin/sh", bindir)
         if shell != "bin/sh":
diff --git a/test/pacman/util.py b/test/pacman/util.py
index 62f88f9..77dd804 100644
--- a/test/pacman/util.py
+++ b/test/pacman/util.py
@@ -55,6 +55,10 @@ def vprint(msg):
 
 sys_maxsize = sys.maxsize if sys.hexversion >= 0x02060000 else sys.maxint
 
+# 2.5 won't accept 0o#, and 3.x won't accept 0#, so...
+PERM_DIR  = int("755",8) # 0o755
+PERM_FILE = int("644",8) # 0o644
+
 
 #
 # Methods to generate files
@@ -93,12 +97,12 @@ def mkfile(base, name, data=""):
     path = os.path.join(base, filename)
     if info["isdir"]:
         if not os.path.isdir(path):
-            os.makedirs(path, 0755)
+            os.makedirs(path, PERM_DIR)
         return
 
     dir_path = os.path.dirname(path)
     if dir_path and not os.path.isdir(dir_path):
-        os.makedirs(dir_path, 0755)
+        os.makedirs(dir_path, PERM_DIR)
 
     if info["islink"]:
         os.symlink(info["link"], path)
@@ -191,6 +195,6 @@ def mkdir(path):
         return
     elif os.path.isfile(path):
         raise OSError("'%s' already exists and is not a directory" % path)
-    os.makedirs(path, 0755)
+    os.makedirs(path, PERM_DIR)
 
 # vim: set ts=4 sw=4 et:
-- 
1.8.4



More information about the pacman-dev mailing list