Blame SOURCES/0020-python-Use-ipaddress-instead-of-IPy.patch

0cec52
From b2512e2a92a33360639a3459039cdf2e685655a8 Mon Sep 17 00:00:00 2001
0cec52
From: Petr Lautrbach <plautrba@redhat.com>
0cec52
Date: Mon, 3 Dec 2018 14:40:09 +0100
709a1f
Subject: [PATCH] python: Use ipaddress instead of IPy
0cec52
0cec52
ipaddress module was added in python 3.3 and this allows us to drop python3-IPy
0cec52
---
0cec52
 python/semanage/seobject.py | 12 ++++++------
0cec52
 1 file changed, 6 insertions(+), 6 deletions(-)
0cec52
0cec52
diff --git a/python/semanage/seobject.py b/python/semanage/seobject.py
0cec52
index b90b1070..58497e3b 100644
0cec52
--- a/python/semanage/seobject.py
0cec52
+++ b/python/semanage/seobject.py
0cec52
@@ -32,7 +32,7 @@ from semanage import *
0cec52
 PROGNAME = "selinux-python"
0cec52
 import sepolicy
0cec52
 import setools
0cec52
-from IPy import IP
0cec52
+import ipaddress
0cec52
 
0cec52
 try:
0cec52
     import gettext
0cec52
@@ -1851,13 +1851,13 @@ class nodeRecords(semanageRecords):
0cec52
 
0cec52
         # verify valid comination
0cec52
         if len(mask) == 0 or mask[0] == "/":
0cec52
-            i = IP(addr + mask)
0cec52
-            newaddr = i.strNormal(0)
0cec52
-            newmask = str(i.netmask())
0cec52
-            if newmask == "0.0.0.0" and i.version() == 6:
0cec52
+            i = ipaddress.ip_network(addr + mask)
0cec52
+            newaddr = str(i.network_address)
0cec52
+            newmask = str(i.netmask)
0cec52
+            if newmask == "0.0.0.0" and i.version == 6:
0cec52
                 newmask = "::"
0cec52
 
0cec52
-            protocol = "ipv%d" % i.version()
0cec52
+            protocol = "ipv%d" % i.version
0cec52
 
0cec52
         try:
0cec52
             newprotocol = self.protocol.index(protocol)
0cec52
-- 
0cec52
2.21.0
0cec52