Hello,
Here are some more Python3 patches. Most are pretty routine, but pay
special attention to the first and last patch.
With these patches, running the in-tree test suite gives me the same
errors in Python 2 and Python 3, except:
- test_install – failures in the updater that I haven't investigated yet
- test_ipaserver – test bug (relying on order of values in an LDAP
attribute) and a text/bytes issue in certificate parsing
In the next few months, I'll need to focus less on IPA and more on
Samba, which is a prerequisite for porting the IPA server. So I'll
quickly summarize the current state of the porting effort:
All of FreeIPA's dependencies except Samba are ported to Python 3 (and
packaged in Fedora).
A recent change switched the IPA client to running on Python 3. With the
patches I'm sending now, most of the "single machine" tests are passing.
The install scripts will still need some work, as will the server parts
that aren't shared with the client.
I'd like to ask the IPA team to sometimes take a look at the Python 3
tests, and try to avoid too many regressions.
--
Petr Viktorin
From 3a645b39f2ab80e60dd2dbcd5f6f4e39946d4450 Mon Sep 17 00:00:00 2001
From: Petr Viktorin
Date: Fri, 29 Apr 2016 17:13:08 +0200
Subject: [PATCH] ipaldap: Keep attribute names as text, not bytes
Part of the work for: https://fedorahosted.org/freeipa/ticket/4985
---
ipapython/ipaldap.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py
index 7e920e1003d84b729547d75d8e1324d2f73c120c..74add512adb6af092e9220c0ca2164c95caae262 100644
--- a/ipapython/ipaldap.py
+++ b/ipapython/ipaldap.py
@@ -813,7 +813,7 @@ class LDAPClient(object):
If there is a problem loading the schema or the attribute is
not in the schema return None
"""
-if isinstance(name_or_oid, unicode):
+if six.PY2 and isinstance(name_or_oid, unicode):
name_or_oid = name_or_oid.encode('utf-8')
if name_or_oid in self._SINGLE_VALUE_OVERRIDE:
@@ -1516,7 +1516,7 @@ class LDAPClient(object):
# pass arguments to python-ldap
with self.error_handler():
-modlist = [(a, self.encode(b), self.encode(c))
+modlist = [(a, str(b), self.encode(c))
for a, b, c in modlist]
self.conn.modify_s(str(entry.dn), modlist)
--
2.5.5
From 85a4c73ca57e1f3ba64bdb76c386b6a9c32f9d36 Mon Sep 17 00:00:00 2001
From: Petr Viktorin
Date: Fri, 6 May 2016 17:08:18 +0200
Subject: [PATCH] ipapython.secrets.kem: Use ConfigParser from six.moves
In Python 3, the module name changed from 'ConfigParser' to
'configparser'. Use the appropriate location from six.
Part of the work for: https://fedorahosted.org/freeipa/ticket/4985
---
ipapython/secrets/kem.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ipapython/secrets/kem.py b/ipapython/secrets/kem.py
index 1025ed7980f055c82c602634e8845fa490cf0514..0abf28ae4403a7b6225404df361d12cb07ccc70b 100644
--- a/ipapython/secrets/kem.py
+++ b/ipapython/secrets/kem.py
@@ -2,7 +2,7 @@
from __future__ import print_function
from ipaplatform.paths import paths
-import ConfigParser
+from six.moves.configparser import ConfigParser
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import rsa, ec
@@ -154,7 +154,7 @@ class IPAKEMKeys(KEMKeysStore):
def __init__(self, config=None, ipaconf=paths.IPA_DEFAULT_CONF):
super(IPAKEMKeys, self).__init__(config)
-conf = ConfigParser.ConfigParser()
+conf = ConfigParser()
conf.read(ipaconf)
self.host = conf.get('global', 'host')
self.realm = conf.get('global', 'realm')
--
2.5.5
From f5d3da6a63a41b626bc9c1b4ac7f6603e220d6ff Mon Sep 17 00:00:00 2001
From: Petr Viktorin
Date: Fri, 6 May 2016 17:35:26 +0200
Subject: [PATCH] test_topology_plugin: Don't rely on order of an attribute's
values
Order of Python dicts/sets was always unreliable, but in Python 3
it's usually different every time. This affects the order in which
values of a LDAP attribute appear.
LDAP values are also specified to be unordered.
Part of the work for: https://fedorahosted.org/freeipa/ticket/4985
---
ipatests/test_ipaserver/test_topology_plugin.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ipatests/test_ipaserver/test_topology_plugin.py b/ipatests/test_ipaserver/test_topology_plugin.py
index 6407f3e6f4ef4ff0fe12de721749dd41a667885c..eaa7b01cb977e885a731e83d0a31597cf7a05168 100644
--- a/ipatests/test_ipaserver/test_topology_plugin.py
+++ b/ipatests/test_ipaserver/test_topology_plugin.py
@@ -72,4 +72,4 @@ class TestTopologyPlugin(object):
entry = self.conn.get_entry(topoplugindn)
assert(set(entry.keys()) == set(pluginattrs.keys()))
for