[apparmor] [patch] backport python3 compability patch to 2.8 branch

Christian Boltz apparmor at cboltz.de
Mon May 6 21:54:58 UTC 2013


Hello,

I'd like to propose the python3 compability changes from trunk r2052 to 
the 2.8 branch.

Most of trunk r2052 also applies to the 2.8 branch. The only difference
is one part for utils/vim/create-apparmor.vim.py:

Trunk r2052 has:
create-apparmor.vim.py
@@ -164,16 +163,16 @@
 
 regex = "@@(" + "|".join(aa_regex_map) + ")@@"
 
-print '" generated from apparmor.vim.in by create-apparmor.vim.py'
-print '" do not edit this file - edit apparmor.vim.in or create-apparmor.vim.py instead' + "\n"
+sys.stdout.write('" generated from apparmor.vim.in by create-apparmor.vim.py\n')
+sys.stdout.write('" do not edit this file - edit apparmor.vim.in or create-apparmor.vim.py instead' + "\n\n")
 
-with file("apparmor.vim.in") as template:
+with open("apparmor.vim.in") as template:
     for line in template:
         line = re.sub(regex, my_repl, line.rstrip())
-        print line
-
-print "\n\n\n"
-
-print '" file rules added with create_file_rule()'
-print re.sub(regex, my_repl, filerule)
+        sys.stdout.write('%s\n' % line)
+
+sys.stdout.write("\n\n\n\n")
+
+sys.stdout.write('" file rules added with create_file_rule()\n')
+sys.stdout.write(re.sub(regex, my_repl, filerule)+'\n')
 

The patch I'm proposing just has
create-apparmor.vim.py
@@ -113,7 +112,8 @@ def my_repl(matchobj):
 
 regex = "@@(" + "|".join(aa_regex_map) + ")@@"
 
-with file("apparmor.vim.in") as template:
+with open("apparmor.vim.in") as template:
     for line in template:
         line = re.sub(regex, my_repl, line.rstrip())
-        print line
+        sys.stdout.write('%s\n' % line)
+#        print line


See the attachment for the full patch.


Regards,

Christian Boltz
-- 
the issue has been fixed and everybody moved on to breaking  
other stuff :)  [Dominique Leuenberger in opensuse-factory]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: apparmor-python3-r2052.diff
Type: text/x-patch
Size: 15879 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20130506/14541b3e/attachment.bin>


More information about the AppArmor mailing list