Re: [PATCH] policycoreutils/semanage: improve compatibility with Python 3 in seobject.py

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 07/30/2015 10:04 AM, Jason Zaman wrote:
On Thu, Jul 30, 2015 at 09:25:15AM +0200, Michal Srb wrote:
- replace print statement with print function
- use reserved word `as` in try-except
- work with dict.keys() in a way compatible with both Python 2 and 3

Signed-off-by: Michal Srb <msrb@xxxxxxxxxx>
---
  policycoreutils/semanage/seobject.py | 118 +++++++++++++++++------------------
  1 file changed, 59 insertions(+), 59 deletions(-)

diff --git a/policycoreutils/semanage/seobject.py b/policycoreutils/semanage/seobject.py
index d29dba5..edd4c83 100644
--- a/policycoreutils/semanage/seobject.py
+++ b/policycoreutils/semanage/seobject.py
@@ -716,7 +716,7 @@ class loginRecords(semanageRecords):
      def customized(self):
          l = []
          ddict = self.get_all(True)
-        keys = ddict.keys()
+        keys = list(ddict.keys())
          keys.sort()
          for k in keys:
              l.append("-a -s %s -r '%s' %s" % (ddict[k][0], ddict[k][1], k))
Isnt it better to do keys = sorted(ddict.keys()) here instead? then the
explicit call to list() isnt required which would hurt on python3.

You're right. sorted() looks better. I will modify the patch and send it again.

Michal


-- Jason

_______________________________________________
Selinux mailing list
Selinux@xxxxxxxxxxxxx
To unsubscribe, send email to Selinux-leave@xxxxxxxxxxxxx.
To get help, send an email containing "help" to Selinux-request@xxxxxxxxxxxxx.



[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux