On 09/07/2015 08:02 AM, Jan Cholasta wrote:
> On 3.9.2015 19:23, Petr Viktorin wrote:
>> On 09/01/2015 04:47 PM, Jan Cholasta wrote:
>>> Hi,
>>>
>>> the attached patches add some more modernization to our code.
[...]
>> 484:
>> To avoid merge conflicts later, perhaps it would be better to have
>>
>>      if six.PY3:
>>          unicode = str
>>
>> at the start of each affected file, instead of scattering changes in the
>> files?
>> (I can prepare the patch if you agree)
> 
> (Be my guest)
> 
>>
>>
>> 485:
>> six.binary_type is named "bytes" since Python 2.6. I think it would be
>> better to use that, to avoid another change when py2 is dropped.
>> (I can prepare the patch here, too)
> 
> (OK)
> 
>>
>>
>> 486: ACK

Here are the two patches updated to use "unicode" and "bytes".


-- 
Petr Viktorin
From 8ffd5c92767b5c49c1ab03aca08cc3fceb3bbeaf Mon Sep 17 00:00:00 2001
From: Jan Cholasta <jchol...@redhat.com>
Date: Fri, 11 Sep 2015 13:43:28 +0200
Subject: [PATCH] Alias "unicode" to "str" under Python 3

The six way of doing this is to replace all occurences of "unicode"
with "six.text_type". However, "unicode" is non-ambiguous and
(arguably) easier to read. Also, using it makes the patches smaller,
which should help with backporting.
---
 doc/examples/examples.py                                     | 6 ++++++
 install/certmonger/dogtag-ipa-ca-renew-agent-submit          | 6 ++++++
 install/oddjob/com.redhat.idm.trust-fetch-domains            | 5 +++++
 install/tools/ipa-adtrust-install                            | 4 ++++
 ipa-client/ipaclient/ipachangeconf.py                        | 4 ++++
 ipalib/cli.py                                                | 3 +++
 ipalib/config.py                                             | 2 ++
 ipalib/frontend.py                                           | 4 ++++
 ipalib/krb_utils.py                                          | 5 +++++
 ipalib/messages.py                                           | 2 ++
 ipalib/output.py                                             | 4 ++++
 ipalib/parameters.py                                         | 3 +++
 ipalib/pkcs10.py                                             | 5 +++++
 ipalib/plugable.py                                           | 5 +++++
 ipalib/plugins/aci.py                                        | 5 +++++
 ipalib/plugins/automember.py                                 | 4 ++++
 ipalib/plugins/automount.py                                  | 5 +++++
 ipalib/plugins/baseldap.py                                   | 3 +++
 ipalib/plugins/baseuser.py                                   | 3 +++
 ipalib/plugins/batch.py                                      | 5 +++++
 ipalib/plugins/cert.py                                       | 5 +++++
 ipalib/plugins/dns.py                                        | 3 +++
 ipalib/plugins/group.py                                      | 3 +++
 ipalib/plugins/hbactest.py                                   | 4 ++++
 ipalib/plugins/host.py                                       | 5 +++++
 ipalib/plugins/hostgroup.py                                  | 5 +++++
 ipalib/plugins/idrange.py                                    | 5 +++++
 ipalib/plugins/idviews.py                                    | 5 +++++
 ipalib/plugins/migration.py                                  | 5 +++++
 ipalib/plugins/netgroup.py                                   | 4 ++++
 ipalib/plugins/otptoken.py                                   | 5 +++++
 ipalib/plugins/otptoken_yubikey.py                           | 4 ++++
 ipalib/plugins/permission.py                                 | 3 +++
 ipalib/plugins/pwpolicy.py                                   | 5 +++++
 ipalib/plugins/realmdomains.py                               | 4 ++++
 ipalib/plugins/service.py                                    | 4 ++++
 ipalib/plugins/servicedelegation.py                          | 5 +++++
 ipalib/plugins/stageuser.py                                  | 6 ++++++
 ipalib/plugins/sudorule.py                                   | 4 ++++
 ipalib/plugins/topology.py                                   | 4 ++++
 ipalib/plugins/trust.py                                      | 5 +++++
 ipalib/plugins/user.py                                       | 5 +++++
 ipalib/rpc.py                                                | 3 +++
 ipalib/text.py                                               | 3 +++
 ipalib/util.py                                               | 3 +++
 ipapython/dn.py                                              | 3 +++
 ipapython/dnsutil.py                                         | 3 +++
 ipapython/dogtag.py                                          | 4 ++++
 ipapython/ipaldap.py                                         | 3 +++
 ipapython/ssh.py                                             | 5 +++++
 ipapython/sysrestore.py                                      | 5 +++++
 ipaserver/dcerpc.py                                          | 4 ++++
 ipaserver/install/adtrustinstance.py                         | 4 ++++
 ipaserver/install/bindinstance.py                            | 3 +++
 ipaserver/install/installutils.py                            | 4 ++++
 ipaserver/install/ipa_ldap_updater.py                        | 5 +++++
 ipaserver/install/ipa_otptoken_import.py                     | 3 +++
 ipaserver/install/ipa_winsync_migrate.py                     | 5 +++++
 ipaserver/install/plugins/rename_managed.py                  | 6 ++++++
 ipaserver/install/plugins/update_managed_permissions.py      | 5 +++++
 ipaserver/install/server/install.py                          | 5 +++++
 ipaserver/install/server/upgrade.py                          | 5 +++++
 ipaserver/plugins/dogtag.py                                  | 4 ++++
 ipaserver/plugins/join.py                                    | 5 +++++
 ipaserver/rpcserver.py                                       | 4 ++++
 ipatests/test_cmdline/test_cli.py                            | 4 ++++
 ipatests/test_cmdline/test_help.py                           | 4 ++++
 ipatests/test_ipalib/test_base.py                            | 5 +++++
 ipatests/test_ipalib/test_errors.py                          | 5 +++++
 ipatests/test_ipalib/test_frontend.py                        | 6 ++++++
 ipatests/test_ipalib/test_parameters.py                      | 3 +++
 ipatests/test_ipalib/test_rpc.py                             | 5 +++++
 ipatests/test_ipalib/test_text.py                            | 6 ++++++
 ipatests/test_ipapython/test_dn.py                           | 5 +++++
 ipatests/test_ipapython/test_ssh.py                          | 6 ++++++
 ipatests/test_ipaserver/test_install/test_adtrustinstance.py | 5 +++++
 ipatests/test_ipaserver/test_ldap.py                         | 4 ++++
 ipatests/test_ipaserver/test_rpcserver.py                    | 5 +++++
 ipatests/test_util.py                                        | 5 +++++
 ipatests/test_xmlrpc/test_automount_plugin.py                | 4 ++++
 ipatests/test_xmlrpc/test_cert_plugin.py                     | 4 ++++
 ipatests/test_xmlrpc/test_dns_realmdomains_integration.py    | 5 +++++
 ipatests/test_xmlrpc/test_idviews_plugin.py                  | 5 +++++
 ipatests/test_xmlrpc/test_radiusproxy_plugin.py              | 5 +++++
 ipatests/test_xmlrpc/test_range_plugin.py                    | 5 +++++
 ipatests/test_xmlrpc/test_stageuser_plugin.py                | 5 +++++
 ipatests/test_xmlrpc/test_sudorule_plugin.py                 | 5 +++++
 ipatests/test_xmlrpc/test_trust_plugin.py                    | 5 +++++
 ipatests/test_xmlrpc/testcert.py                             | 5 +++++
 ipatests/util.py                                             | 3 +++
 90 files changed, 394 insertions(+)

diff --git a/doc/examples/examples.py b/doc/examples/examples.py
index 4ac415f1af57fd2ddf101a2e2ce1e57b10b2916b..baf3963d60533f9788d3c5816776f55045dac49b 100644
--- a/doc/examples/examples.py
+++ b/doc/examples/examples.py
@@ -42,6 +42,12 @@
 from ipalib import output
 
 
+# To make the example ready for Python 3, we alias "unicode" to strings.
+import six
+if six.PY3:
+    unicode = str
+
+
 # We're going to create an example command plugin, that takes a name as its
 # only argument. Commands in IPA support input validation by defining
 # functions we're going to call 'validators'. This is an example of such
diff --git a/install/certmonger/dogtag-ipa-ca-renew-agent-submit b/install/certmonger/dogtag-ipa-ca-renew-agent-submit
index 9f65b0515e4b3b4b973fa934595d46338f6a92c0..44993b038a38da60a25843147e86b64deda874e1 100755
--- a/install/certmonger/dogtag-ipa-ca-renew-agent-submit
+++ b/install/certmonger/dogtag-ipa-ca-renew-agent-submit
@@ -35,6 +35,8 @@ import base64
 import contextlib
 import json
 
+import six
+
 from ipapython import ipautil
 from ipapython.dn import DN
 from ipalib import api, errors, pkcs10, x509
@@ -56,6 +58,10 @@ UNCONFIGURED = 4
 WAIT_WITH_DELAY = 5
 OPERATION_NOT_SUPPORTED_BY_HELPER = 6
 
+if six.PY3:
+    unicode = str
+
+
 @contextlib.contextmanager
 def ldap_connect():
     conn = None
diff --git a/install/oddjob/com.redhat.idm.trust-fetch-domains b/install/oddjob/com.redhat.idm.trust-fetch-domains
index 138779c0cda6bad4840b502f973b39bdea1fefbf..019545b9340ac95f4e528618875df3dcd8170feb 100755
--- a/install/oddjob/com.redhat.idm.trust-fetch-domains
+++ b/install/oddjob/com.redhat.idm.trust-fetch-domains
@@ -10,8 +10,13 @@ from ipalib.constants import DEFAULT_CONFIG
 from ipapython.ipautil import kinit_keytab
 import sys
 import os, pwd
+
+import six
 import gssapi
 
+if six.PY3:
+    unicode = str
+
 def retrieve_keytab(api, ccache_name, oneway_keytab_name, oneway_principal):
     getkeytab_args = ["/usr/sbin/ipa-getkeytab",
                       "-s", api.env.host,
diff --git a/install/tools/ipa-adtrust-install b/install/tools/ipa-adtrust-install
index 9ff1ac9be24a9f16f59ebe8dd46b2ff0d27b06aa..5bece0d8b6f1b0aeced5fbeb7b5e7ba1ae019fd9 100755
--- a/install/tools/ipa-adtrust-install
+++ b/install/tools/ipa-adtrust-install
@@ -23,6 +23,7 @@
 
 from __future__ import print_function
 
+import six
 import gssapi
 
 from ipaserver.install import adtrustinstance
@@ -36,6 +37,9 @@ from ipaplatform.paths import paths
 from ipapython.ipa_log_manager import *
 from ipapython.dn import DN
 
+if six.PY3:
+    unicode = str
+
 log_file_name = paths.IPASERVER_INSTALL_LOG
 
 def parse_options():
diff --git a/ipa-client/ipaclient/ipachangeconf.py b/ipa-client/ipaclient/ipachangeconf.py
index a1ebb4f638604fc2e7b4a1fb8c7980cd1bc61c95..ef4c98776d9a782bb98a248a29426ec4a10dcdc5 100644
--- a/ipa-client/ipaclient/ipachangeconf.py
+++ b/ipa-client/ipaclient/ipachangeconf.py
@@ -24,6 +24,10 @@
 import time
 import shutil
 
+import six
+
+if six.PY3:
+    unicode = str
 
 def openLocked(filename, perms):
     fd = -1
diff --git a/ipalib/cli.py b/ipalib/cli.py
index 206664a8886b1e25acffaa8c3e9325fe9921d1c5..347d4c788c19ae3f2c23bda1094fe1691fa073da 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -36,6 +36,9 @@
 import six
 from six.moves import input
 
+if six.PY3:
+    unicode = str
+
 try:
     #pylint: disable=F0401
     import default_encoding_utf8
diff --git a/ipalib/config.py b/ipalib/config.py
index 1441274675fe767f8fc5db55a6a039f21d4fc9ac..14368e2b40cc7bd641a0bacdac2d567f25e3a1b5 100644
--- a/ipalib/config.py
+++ b/ipalib/config.py
@@ -43,6 +43,8 @@
 from ipalib.constants import CONFIG_SECTION
 from ipalib.constants import OVERRIDE_ERROR, SET_ERROR, DEL_ERROR
 
+if six.PY3:
+    unicode = str
 
 class Env(object):
     """
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index fbada31a8c69fedba1f27ac3b9ae250591871fe0..4c7563a6b4f1d6a118175bc3ce94c14d650d2089 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -25,6 +25,8 @@
 from distutils import version
 from textwrap import wrap
 
+import six
+
 from ipapython.version import API_VERSION
 from ipapython.ipa_log_manager import root_logger
 from ipalib.capabilities import VERSION_WITHOUT_CAPABILITIES
@@ -39,6 +41,8 @@
 from ipalib import messages
 from ipalib.util import json_serialize
 
+if six.PY3:
+    unicode = str
 
 RULE_FLAG = 'validation_rule'
 
diff --git a/ipalib/krb_utils.py b/ipalib/krb_utils.py
index db1cffc1e32a2e50fba64897ff1eba005f90fdc3..a1a96a8c248f0f4ca59c1178c40f283e72e84075 100644
--- a/ipalib/krb_utils.py
+++ b/ipalib/krb_utils.py
@@ -18,10 +18,15 @@
 
 import time
 import re
+
+import six
 import gssapi
 
 from ipalib import errors
 
+if six.PY3:
+    unicode = str
+
 #-------------------------------------------------------------------------------
 
 # Kerberos error codes
diff --git a/ipalib/messages.py b/ipalib/messages.py
index da8f740beabec328e391bc4c2f53b87bfcb533b6..375da244328f892eee686c9787524d4a6709c0ce 100644
--- a/ipalib/messages.py
+++ b/ipalib/messages.py
@@ -40,6 +40,8 @@
 from ipalib.text import Gettext, NGettext
 from ipalib.capabilities import client_has_capability
 
+if six.PY3:
+    unicode = str
 
 def add_message(version, result, message):
     if client_has_capability(version, 'messages'):
diff --git a/ipalib/output.py b/ipalib/output.py
index 68b2bf933d12e00567bb5612cc4c5ca0e542cae9..1398a6cb812f7e022d96b6ca92adf52e4c4945ca 100644
--- a/ipalib/output.py
+++ b/ipalib/output.py
@@ -24,10 +24,14 @@
 from inspect import getdoc
 from types import NoneType
 
+import six
+
 from ipalib.plugable import ReadOnly, lock
 from ipalib.capabilities import client_has_capability
 from ipalib.text import _
 
+if six.PY3:
+    unicode = str
 
 class Output(ReadOnly):
     """
diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index 5b21cfb234c112369706af1e58f567adad63c499..a03a75d83e6783f405012903a6b9c868b68e64d2 100644
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ -123,6 +123,9 @@
 def _is_null(value):
     return not value and value != 0 # NOTE: False == 0
 
+if six.PY3:
+    unicode = str
+
 class DefaultFrom(ReadOnly):
     """
     Derive a default value from other supplied values.
diff --git a/ipalib/pkcs10.py b/ipalib/pkcs10.py
index 1a544b156c030103d0948c191e7d48a0722f4951..7b0d8f733b88811352b8fc02aad9db1e36b61dfd 100644
--- a/ipalib/pkcs10.py
+++ b/ipalib/pkcs10.py
@@ -25,9 +25,14 @@
 import nss.nss as nss
 from pyasn1.type import univ, char, namedtype, tag
 from pyasn1.codec.der import decoder
+import six
+
 from ipapython import ipautil
 from ipalib import api
 
+if six.PY3:
+    unicode = str
+
 PEM = 0
 DER = 1
 
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index 3f65f6736295ec9ddb69bc7595cbc44b7d563042..2a608d8cb67a65e2dcebf2531585b96bab01a3b0 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -36,6 +36,8 @@
 import collections
 import importlib
 
+import six
+
 from ipalib import errors
 from ipalib.config import Env
 from ipalib import text
@@ -45,6 +47,9 @@
 from ipapython.ipa_log_manager import *
 from ipapython.version import VERSION, API_VERSION
 
+if six.PY3:
+    unicode = str
+
 # FIXME: Updated constants.TYPE_ERROR to use this clearer format from wehjit:
 TYPE_ERROR = '%s: need a %r; got a %r: %r'
 
diff --git a/ipalib/plugins/aci.py b/ipalib/plugins/aci.py
index 5aa486db895b30b7971b95bd82abcd2fa8044281..8fe382f38808f790b59bb7304b2045507049d31f 100644
--- a/ipalib/plugins/aci.py
+++ b/ipalib/plugins/aci.py
@@ -119,6 +119,8 @@
 """
 from copy import deepcopy
 
+import six
+
 from ipalib import api, crud, errors
 from ipalib import Object
 from ipalib import Flag, Str, StrEnum, DNParam
@@ -130,6 +132,9 @@
 from ipapython.ipa_log_manager import *
 from ipapython.dn import DN
 
+if six.PY3:
+    unicode = str
+
 register = Registry()
 
 ACI_NAME_PREFIX_SEP = ":"
diff --git a/ipalib/plugins/automember.py b/ipalib/plugins/automember.py
index 0c2a246e1c24b36525f61b47878860f4056569fc..a45fab07b18633b8800eff81e00cfa4948e61c64 100644
--- a/ipalib/plugins/automember.py
+++ b/ipalib/plugins/automember.py
@@ -20,6 +20,7 @@
 import time
 
 import ldap as _ldap
+import six
 
 from ipalib import api, errors, Str, StrEnum, DNParam, _, ngettext
 from ipalib.plugable import Registry
@@ -27,6 +28,9 @@
 from ipalib.request import context
 from ipapython.dn import DN
 
+if six.PY3:
+    unicode = str
+
 __doc__ = _("""
 Auto Membership Rule.
 """) + _("""
diff --git a/ipalib/plugins/automount.py b/ipalib/plugins/automount.py
index 304bed71fc833b80a994e4bcdace09227bc25a63..a909f6c390174ec9a9492c207cb84120d3da39f1 100644
--- a/ipalib/plugins/automount.py
+++ b/ipalib/plugins/automount.py
@@ -20,6 +20,8 @@
 
 import os
 
+import six
+
 from ipalib import api, errors
 from ipalib import Object, Command
 from ipalib import Flag, Str, IA5Str
@@ -27,6 +29,9 @@
 from ipalib.plugins.baseldap import *
 from ipalib import _, ngettext
 
+if six.PY3:
+    unicode = str
+
 __doc__ = _("""
 Automount
 
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py
index 8a375afba1835f90977b8ac44970062637eabfaa..81fae151693d3188c8c5b7bebf97b13a20fcf319 100644
--- a/ipalib/plugins/baseldap.py
+++ b/ipalib/plugins/baseldap.py
@@ -38,6 +38,9 @@
 from ipapython.dn import DN, RDN
 from ipapython.version import API_VERSION
 
+if six.PY3:
+    unicode = str
+
 DNA_MAGIC = -1
 
 global_output_params = (
diff --git a/ipalib/plugins/baseuser.py b/ipalib/plugins/baseuser.py
index ed7c1a9d360a89ce0640dd63e748596993bb8b6c..b974e3fb18659e7eb6e75557e0d4db3ec1197dcd 100644
--- a/ipalib/plugins/baseuser.py
+++ b/ipalib/plugins/baseuser.py
@@ -41,6 +41,9 @@
 from ipalib.util import (normalize_sshpubkey, validate_sshpubkey,
     convert_sshpubkey_post)
 
+if six.PY3:
+    unicode = str
+
 __doc__ = _("""
 Baseuser
 
diff --git a/ipalib/plugins/batch.py b/ipalib/plugins/batch.py
index ddf24839ddd9af489fee53311daba9b88a706d22..7a4cda2a0c8bcab4ac590661fd7b4053a9e38e42 100644
--- a/ipalib/plugins/batch.py
+++ b/ipalib/plugins/batch.py
@@ -45,6 +45,8 @@
 
 """
 
+import six
+
 from ipalib import api, errors
 from ipalib import Command
 from ipalib.parameters import Str, Any
@@ -55,6 +57,9 @@
 from ipalib.plugable import Registry
 from ipapython.version import API_VERSION
 
+if six.PY3:
+    unicode = str
+
 register = Registry()
 
 @register()
diff --git a/ipalib/plugins/cert.py b/ipalib/plugins/cert.py
index 1fd5fb67f966b7b2539375f6973243a0bcb002bc..e4593200e01addea31c8fcda981fbe1d65058c27 100644
--- a/ipalib/plugins/cert.py
+++ b/ipalib/plugins/cert.py
@@ -40,10 +40,15 @@
 from ipalib.request import context
 from ipalib import output
 from ipalib.plugins.service import validate_principal
+
+import six
 import nss.nss as nss
 from nss.error import NSPRError
 from pyasn1.error import PyAsn1Error
 
+if six.PY3:
+    unicode = str
+
 __doc__ = _("""
 IPA certificate operations
 
diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index be0639b6ada1b95364dc53a42f8a762e0671fe1a..84086f4c77d02922f237937d58031cc42d55410e 100644
--- a/ipalib/plugins/dns.py
+++ b/ipalib/plugins/dns.py
@@ -56,6 +56,9 @@
 from ipapython.ipautil import CheckedIPAddress, is_host_resolvable
 from ipapython.dnsutil import DNSName
 
+if six.PY3:
+    unicode = str
+
 __doc__ = _("""
 Domain Name System (DNS)
 """) + _("""
diff --git a/ipalib/plugins/group.py b/ipalib/plugins/group.py
index 8ee20a9a8e47ec0f3b1cda3ada08d80a9fdb1024..64a135e01769baaec02523d3251e2847d357085e 100644
--- a/ipalib/plugins/group.py
+++ b/ipalib/plugins/group.py
@@ -28,6 +28,9 @@
 from ipalib.plugins import baseldap
 from ipalib import _, ngettext
 
+if six.PY3:
+    unicode = str
+
 if api.env.in_server and api.env.context in ['lite', 'server']:
     try:
         import ipaserver.dcerpc
diff --git a/ipalib/plugins/hbactest.py b/ipalib/plugins/hbactest.py
index c8dedd367e78cbe900b716369f8ef78575a21298..b528707f785c711ce6449237ea789d56cda2dcbb 100644
--- a/ipalib/plugins/hbactest.py
+++ b/ipalib/plugins/hbactest.py
@@ -32,6 +32,10 @@
         _dcerpc_bindings_installed = False
 
 import pyhbac
+import six
+
+if six.PY3:
+    unicode = str
 
 __doc__ = _("""
 Simulate use of Host-based access controls
diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py
index 532ff66607911cfd8e1a3407b0f361641bb7992b..bceab314b8acb496e885a889311e026cabfb2a47 100644
--- a/ipalib/plugins/host.py
+++ b/ipalib/plugins/host.py
@@ -21,6 +21,8 @@
 from nss.error import NSPRError
 import string
 
+import six
+
 from ipalib import api, errors, util
 from ipalib import Str, Flag, Bytes
 from ipalib.plugable import Registry
@@ -49,6 +51,9 @@
 from ipapython.dn import DN
 from functools import reduce
 
+if six.PY3:
+    unicode = str
+
 __doc__ = _("""
 Hosts/Machines
 
diff --git a/ipalib/plugins/hostgroup.py b/ipalib/plugins/hostgroup.py
index 30d474d80905f02c4f88742a2677220c150b3c7f..596290fcdc344a586aa8191d3fc67c7f896dec5e 100644
--- a/ipalib/plugins/hostgroup.py
+++ b/ipalib/plugins/hostgroup.py
@@ -18,6 +18,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import six
+
 from ipalib.plugable import Registry
 from ipalib.plugins.baseldap import (LDAPObject, LDAPCreate, LDAPRetrieve,
                                      LDAPDelete, LDAPUpdate, LDAPSearch,
@@ -27,6 +29,9 @@
 from ipalib.plugins.netgroup import NETGROUP_PATTERN, NETGROUP_PATTERN_ERRMSG
 from ipapython.dn import DN
 
+if six.PY3:
+    unicode = str
+
 __doc__ = _("""
 Groups of hosts.
 
diff --git a/ipalib/plugins/idrange.py b/ipalib/plugins/idrange.py
index 2cec05bd8f837fb27803b869bf33fe389126506c..bec07da2efa8f5600b801bbb37aca576b3250ee1 100644
--- a/ipalib/plugins/idrange.py
+++ b/ipalib/plugins/idrange.py
@@ -17,6 +17,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import six
+
 from ipalib.plugable import Registry
 from ipalib.plugins.baseldap import (LDAPObject, LDAPCreate, LDAPDelete,
                                      LDAPRetrieve, LDAPSearch, LDAPUpdate)
@@ -24,6 +26,9 @@
 from ipalib import errors
 from ipapython.dn import DN
 
+if six.PY3:
+    unicode = str
+
 if api.env.in_server and api.env.context in ['lite', 'server']:
     try:
         import ipaserver.dcerpc
diff --git a/ipalib/plugins/idviews.py b/ipalib/plugins/idviews.py
index cf5c9b5e8371c89e89a4cf1d334ac0e6b514653a..a910486cd0160571311924ce799800aa54868dcc 100644
--- a/ipalib/plugins/idviews.py
+++ b/ipalib/plugins/idviews.py
@@ -19,6 +19,8 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 import re
 
+import six
+
 from ipalib.plugins.baseldap import (LDAPQuery, LDAPObject, LDAPCreate,
                                      LDAPDelete, LDAPUpdate, LDAPSearch,
                                      LDAPRetrieve, global_output_params)
@@ -31,6 +33,9 @@
 
 from ipapython.dn import DN
 
+if six.PY3:
+    unicode = str
+
 _dcerpc_bindings_installed = False
 
 if api.env.in_server and api.env.context in ['lite', 'server']:
diff --git a/ipalib/plugins/migration.py b/ipalib/plugins/migration.py
index 3d8d565e0cd25627fd7c2f366b778f4954311979..3e3c0fe19cdcd0ce31b342830b29ca066653b44a 100644
--- a/ipalib/plugins/migration.py
+++ b/ipalib/plugins/migration.py
@@ -21,6 +21,8 @@
 from ldap import MOD_ADD
 from ldap import SCOPE_BASE, SCOPE_ONELEVEL, SCOPE_SUBTREE
 
+import six
+
 from ipalib import api, errors, output
 from ipalib import Command, Password, Str, Flag, StrEnum, DNParam, File, Bool
 from ipalib.cli import to_cli
@@ -37,6 +39,9 @@
 import datetime
 from ipaplatform.paths import paths
 
+if six.PY3:
+    unicode = str
+
 __doc__ = _("""
 Migration to IPA
 
diff --git a/ipalib/plugins/netgroup.py b/ipalib/plugins/netgroup.py
index e69aaf94a035d0c4af28585f84b4b1f8105b3fc3..fe85889dea362cf7f349bbe1ea12be77c3b868f9 100644
--- a/ipalib/plugins/netgroup.py
+++ b/ipalib/plugins/netgroup.py
@@ -18,6 +18,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import six
 
 from ipalib import api, errors
 from ipalib import Str, StrEnum
@@ -26,6 +27,9 @@
 from ipalib import _, ngettext
 from ipalib.plugins.hbacrule import is_all
 
+if six.PY3:
+    unicode = str
+
 __doc__ = _("""
 Netgroups
 
diff --git a/ipalib/plugins/otptoken.py b/ipalib/plugins/otptoken.py
index bb027eea0b140af88b1e60972932e4ec8e2f8b68..651a3ab940abee7cd6551ea2038e82517dfd01aa 100644
--- a/ipalib/plugins/otptoken.py
+++ b/ipalib/plugins/otptoken.py
@@ -38,6 +38,11 @@
 import qrcode
 import os
 
+import six
+
+if six.PY3:
+    unicode = str
+
 __doc__ = _("""
 OTP Tokens
 """) + _("""
diff --git a/ipalib/plugins/otptoken_yubikey.py b/ipalib/plugins/otptoken_yubikey.py
index 58fc18308f0cfe407881b5fbb5e653c5afbd0eba..0cbda1b2e876a166bdc37da5e9cff16b317b2c80 100644
--- a/ipalib/plugins/otptoken_yubikey.py
+++ b/ipalib/plugins/otptoken_yubikey.py
@@ -27,6 +27,10 @@
 
 import usb.core
 import yubico
+import six
+
+if six.PY3:
+    unicode = str
 
 __doc__ = _("""
 YubiKey Tokens
diff --git a/ipalib/plugins/permission.py b/ipalib/plugins/permission.py
index 7a2e14c7245dbdd304b82a057094b80fd1a44e5a..b17b61e696a8f333a25150f60f27cffd03085196 100644
--- a/ipalib/plugins/permission.py
+++ b/ipalib/plugins/permission.py
@@ -33,6 +33,9 @@
 from ipapython.dn import DN
 from ipalib.request import context
 
+if six.PY3:
+    unicode = str
+
 __doc__ = _("""
 Permissions
 """) + _("""
diff --git a/ipalib/plugins/pwpolicy.py b/ipalib/plugins/pwpolicy.py
index 866d57475939a8cd3be4ad883de54eb6f10be101..5e98d5469eac0a3f0094d0485dc5d0aaee299438 100644
--- a/ipalib/plugins/pwpolicy.py
+++ b/ipalib/plugins/pwpolicy.py
@@ -28,6 +28,11 @@
 from ipapython.dn import DN
 from distutils import version
 
+import six
+
+if six.PY3:
+    unicode = str
+
 __doc__ = _("""
 Password policy
 
diff --git a/ipalib/plugins/realmdomains.py b/ipalib/plugins/realmdomains.py
index 871ea79c4b6225919d2700420a56eebb816bc025..f8f838d0ede85ee747a4b2f19129dc757fe837eb 100644
--- a/ipalib/plugins/realmdomains.py
+++ b/ipalib/plugins/realmdomains.py
@@ -17,6 +17,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import six
+
 from ipalib import api, errors
 from ipalib import Str, Flag
 from ipalib import _
@@ -26,6 +28,8 @@
 from ipapython.dn import DN
 from ipapython.ipautil import get_domain_name
 
+if six.PY3:
+    unicode = str
 
 __doc__ = _("""
 Realm domains
diff --git a/ipalib/plugins/service.py b/ipalib/plugins/service.py
index 39285dd5df41486c89e3e8ddc318d7df7d18594e..d63e00bea0dd9a69fd550916337a8cc1a88a93fb 100644
--- a/ipalib/plugins/service.py
+++ b/ipalib/plugins/service.py
@@ -22,6 +22,7 @@
 import base64
 import os
 
+import six
 
 from ipalib import api, errors, util
 from ipalib import Str, Flag, Bytes, StrEnum, Bool
@@ -34,6 +35,9 @@
 from nss.error import NSPRError
 from ipapython.ipautil import file_exists
 
+if six.PY3:
+    unicode = str
+
 __doc__ = _("""
 Services
 
diff --git a/ipalib/plugins/servicedelegation.py b/ipalib/plugins/servicedelegation.py
index 37de916389c46d99f17b66c1cac16e391265491d..2ce11191ba0f08f0c21a11e772972a9fcc7f74f0 100644
--- a/ipalib/plugins/servicedelegation.py
+++ b/ipalib/plugins/servicedelegation.py
@@ -2,6 +2,8 @@
 # Copyright (C) 2015  FreeIPA Contributors see COPYING for license
 #
 
+import six
+
 from ipalib import api
 from ipalib import Str
 from ipalib.plugable import Registry
@@ -9,6 +11,9 @@
 from ipalib.plugins.service import normalize_principal
 from ipalib import _, ngettext
 
+if six.PY3:
+    unicode = str
+
 __doc__ = _("""
 Service Constrained Delegation
 
diff --git a/ipalib/plugins/stageuser.py b/ipalib/plugins/stageuser.py
index 2a232d1e388ab000e8feb8dba47eb342bd73c4c6..00fba1f8329e638a304e3f70d10b89aaf38aaebc 100644
--- a/ipalib/plugins/stageuser.py
+++ b/ipalib/plugins/stageuser.py
@@ -22,6 +22,9 @@
 import posixpath
 import os
 from copy import deepcopy
+
+import six
+
 from ipalib import api, errors
 from ipalib import (Flag, Int, Password, Str, Bool, StrEnum, DateTime,
                     DeprecatedParam)
@@ -44,6 +47,9 @@
 from ipalib.util import (normalize_sshpubkey, validate_sshpubkey,
     convert_sshpubkey_post)
 
+if six.PY3:
+    unicode = str
+
 __doc__ = _("""
 Stageusers
 
diff --git a/ipalib/plugins/sudorule.py b/ipalib/plugins/sudorule.py
index 6844343e1e3ad58f8caf9707ba4a43c21574dfe8..c799a31668fcfde3d99c0a6ad359e40c09be7056 100644
--- a/ipalib/plugins/sudorule.py
+++ b/ipalib/plugins/sudorule.py
@@ -18,6 +18,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import netaddr
+import six
 
 from ipalib import api, errors
 from ipalib import Str, StrEnum, Bool, Int
@@ -35,6 +36,9 @@
 from ipalib.util import validate_hostmask
 from ipapython.dn import DN
 
+if six.PY3:
+    unicode = str
+
 __doc__ = _("""
 Sudo Rules
 """) + _("""
diff --git a/ipalib/plugins/topology.py b/ipalib/plugins/topology.py
index 2723ce1213df2c94fd1445cfe7595d35806028d9..c6b86b5909cf5ef2c02515f7a6cbe4e987a927a9 100644
--- a/ipalib/plugins/topology.py
+++ b/ipalib/plugins/topology.py
@@ -2,6 +2,8 @@
 # Copyright (C) 2015  FreeIPA Contributors see COPYING for license
 #
 
+import six
+
 from ipalib import api, errors
 from ipalib import Int, Str, Bool, StrEnum, Flag
 from ipalib.plugable import Registry
@@ -13,6 +15,8 @@
 from ipalib.util import create_topology_graph, get_topology_connection_errors
 from ipapython.dn import DN
 
+if six.PY3:
+    unicode = str
 
 __doc__ = _("""
 Topology
diff --git a/ipalib/plugins/trust.py b/ipalib/plugins/trust.py
index febe16f1d15627f1203ad9f0704ecb9449f8fd7f..472f3534ecdbfaaee4db5c650cd8f77c511d9dcf 100644
--- a/ipalib/plugins/trust.py
+++ b/ipalib/plugins/trust.py
@@ -18,6 +18,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import six
+
 from ipalib.plugable import Registry
 from ipalib.plugins.baseldap import *
 from ipalib.plugins.dns import dns_container_exists
@@ -29,6 +31,9 @@
 from ldap import SCOPE_SUBTREE
 from time import sleep
 
+if six.PY3:
+    unicode = str
+
 try:
     import pysss_murmur #pylint: disable=F0401
     _murmur_installed = True
diff --git a/ipalib/plugins/user.py b/ipalib/plugins/user.py
index a1e7c8ce713e8735d832db056da1bff956c9cb18..e7f128a331f23ff109107f78456cf0b7f840f82b 100644
--- a/ipalib/plugins/user.py
+++ b/ipalib/plugins/user.py
@@ -23,6 +23,8 @@
 import posixpath
 import os
 
+import six
+
 from ipalib import api, errors, util
 from ipalib import Flag, Int, Password, Str, Bool, StrEnum, DateTime
 from ipalib.plugins.baseuser import baseuser, baseuser_add, baseuser_del, \
@@ -48,6 +50,9 @@
 if api.env.in_server:
     from ipaserver.plugins.ldap2 import ldap2
 
+if six.PY3:
+    unicode = str
+
 __doc__ = _("""
 Users
 
diff --git a/ipalib/rpc.py b/ipalib/rpc.py
index dcbfafe0567d653273fccb96d31d4c407fdf256c..4d39503a76293a60af87b951b5a8990b8af51e8a 100644
--- a/ipalib/rpc.py
+++ b/ipalib/rpc.py
@@ -72,6 +72,9 @@
 from ipalib.capabilities import VERSION_WITHOUT_CAPABILITIES
 from ipalib import api
 
+if six.PY3:
+    unicode = str
+
 COOKIE_NAME = 'ipa_session'
 KEYRING_COOKIE_NAME = '%s_cookie:%%s' % COOKIE_NAME
 
diff --git a/ipalib/text.py b/ipalib/text.py
index 160213eb8015fd2c1370daf68a2af354f8e965d7..9afe4d3009f3fdd44fbf2a8408a3254b0e3c7c92 100644
--- a/ipalib/text.py
+++ b/ipalib/text.py
@@ -120,6 +120,9 @@
 
 from ipalib.request import context
 
+if six.PY3:
+    unicode = str
+
 
 def create_translation(key):
     assert key not in context.__dict__
diff --git a/ipalib/util.py b/ipalib/util.py
index 5a761fb0f7ee6c0851d6f1128cecc4ddd8b397f2..7c7da6af7bbb290dd25832e188d5445a23e5571e 100644
--- a/ipalib/util.py
+++ b/ipalib/util.py
@@ -46,6 +46,9 @@
 from ipapython.dnsutil import DNSName
 from ipapython.graph import Graph
 
+if six.PY3:
+    unicode = str
+
 
 def json_serialize(obj):
     if isinstance(obj, (list, tuple)):
diff --git a/ipapython/dn.py b/ipapython/dn.py
index a3b20121ace815322f2c1142e73182ae9f574caf..5a42ab37e093d294db732aa99d3669167e05e274 100644
--- a/ipapython/dn.py
+++ b/ipapython/dn.py
@@ -425,6 +425,9 @@
 from ldap import DECODING_ERROR
 import six
 
+if six.PY3:
+    unicode = str
+
 __all__ = 'AVA', 'RDN', 'DN'
 
 def _adjust_indices(start, end, length):
diff --git a/ipapython/dnsutil.py b/ipapython/dnsutil.py
index d190f23c7fc6db7a59c3131c0d90b5709fc1e4a5..7844d7bec32602dd53935c104df38fdd4a15f2b2 100644
--- a/ipapython/dnsutil.py
+++ b/ipapython/dnsutil.py
@@ -23,6 +23,9 @@
 
 import six
 
+if six.PY3:
+    unicode = str
+
 
 @six.python_2_unicode_compatible
 class DNSName(dns.name.Name):
diff --git a/ipapython/dogtag.py b/ipapython/dogtag.py
index fe951cf5b504ddef4963466f8b55fa9a2cd37341..305e10a71e7d0da8ac3646959cc8fe28967cc43f 100644
--- a/ipapython/dogtag.py
+++ b/ipapython/dogtag.py
@@ -25,6 +25,7 @@
 from urllib import urlencode
 
 import nss.nss as nss
+import six
 
 from ipalib import api, errors
 from ipalib.errors import NetworkError
@@ -33,6 +34,9 @@
 from ipaplatform.paths import paths
 from ipapython.ipa_log_manager import *
 
+if six.PY3:
+    unicode = str
+
 # IPA can use either Dogtag version 9 or 10.
 #
 # Install tools should use the constants from install_constants, so that they
diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py
index 837d57c3b6fae4caaa04492474dd0757002145b7..9c78dbf69f49c75cc3065627e97b09b59a6889c2 100644
--- a/ipapython/ipaldap.py
+++ b/ipapython/ipaldap.py
@@ -47,6 +47,9 @@
 from ipapython.dn import DN, RDN
 from ipapython.dnsutil import DNSName
 
+if six.PY3:
+    unicode = str
+
 # Global variable to define SASL auth
 SASL_GSSAPI = ldap.sasl.sasl({}, 'GSSAPI')
 
diff --git a/ipapython/ssh.py b/ipapython/ssh.py
index c95488928c727de08fbcbeea27cba4ac9a02a627..c8d8306f22e08e172202f31d25354911bb93d529 100644
--- a/ipapython/ssh.py
+++ b/ipapython/ssh.py
@@ -28,6 +28,11 @@
 from hashlib import md5, sha1
 from hashlib import sha256  #pylint: disable=E0611
 
+import six
+
+if six.PY3:
+    unicode = str
+
 __all__ = ['SSHPublicKey']
 
 OPENSSH_BASE_REGEX = re.compile(r'^[\t ]*(?P<keytype>[^\x00\n\r]+?) [\t ]*(?P<key>[^\x00\n\r]+?)(?:[\t ]+(?P<comment>[^\x00\n\r]*?)[\t ]*)?$')
diff --git a/ipapython/sysrestore.py b/ipapython/sysrestore.py
index 24ddc9a47079cd3f18589120a700fc1e62cb4a89..8ce8e4b7ac4e53046d8597c70b2c552cc66bedc2 100644
--- a/ipapython/sysrestore.py
+++ b/ipapython/sysrestore.py
@@ -31,10 +31,15 @@
 import random
 import string
 
+import six
+
 from ipapython import ipautil
 from ipaplatform.tasks import tasks
 from ipaplatform.paths import paths
 
+if six.PY3:
+    unicode = str
+
 SYSRESTORE_PATH = paths.TMP
 SYSRESTORE_INDEXFILE = "sysrestore.index"
 SYSRESTORE_STATEFILE = "sysrestore.state"
diff --git a/ipaserver/dcerpc.py b/ipaserver/dcerpc.py
index 639f89ff52a765271e4c6f737526dc5124c974b0..77610c6d4d7dbac1e66095828a00265046060c90 100644
--- a/ipaserver/dcerpc.py
+++ b/ipaserver/dcerpc.py
@@ -55,11 +55,15 @@
 from dns.exception import DNSException
 import pysss_nss_idmap
 import pysss
+import six
 from ipaplatform.paths import paths
 
 from ldap.filter import escape_filter_chars
 from time import sleep
 
+if six.PY3:
+    unicode = str
+
 __doc__ = _("""
 Classes to manage trust joins using DCE-RPC calls
 
diff --git a/ipaserver/install/adtrustinstance.py b/ipaserver/install/adtrustinstance.py
index 08b652a107c22be245e7d9cb5598add5d33f4381..acc54ab83383b0b514fcd4f14d7480e0b38cb5b1 100644
--- a/ipaserver/install/adtrustinstance.py
+++ b/ipaserver/install/adtrustinstance.py
@@ -28,6 +28,8 @@
 import struct
 import re
 
+import six
+
 from ipaserver.install import service
 from ipaserver.install import installutils
 from ipaserver.install.bindinstance import get_rr, add_rr, del_rr, \
@@ -45,6 +47,8 @@
 from ipaplatform.paths import paths
 from ipaplatform.tasks import tasks
 
+if six.PY3:
+    unicode = str
 
 ALLOWED_NETBIOS_CHARS = string.ascii_uppercase + string.digits
 
diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py
index c52b1c0d6e1c66d7f245fe86bcb211ed20e81da3..771f13b00e37a6bf510ff46fe880240c84356761 100644
--- a/ipaserver/install/bindinstance.py
+++ b/ipaserver/install/bindinstance.py
@@ -48,6 +48,9 @@
         EDNS0UnsupportedError, UnresolvableRecordError)
 from ipalib.constants import CACERT
 
+if six.PY3:
+    unicode = str
+
 NAMED_CONF = paths.NAMED_CONF
 RESOLV_CONF = paths.RESOLV_CONF
 
diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py
index 49a28a7a2bcab538c591018cadf4d4c33d1d8ce6..ad79f8896302ff3310b7f17fe3edef0ec7081c3a 100644
--- a/ipaserver/install/installutils.py
+++ b/ipaserver/install/installutils.py
@@ -37,6 +37,7 @@
 from dns.exception import DNSException
 import ldap
 from nss.error import NSPRError
+import six
 
 import ipaplatform
 
@@ -52,6 +53,9 @@
 from ipaplatform.paths import paths
 from ipaplatform.tasks import tasks
 
+if six.PY3:
+    unicode = str
+
 # Used to determine install status
 IPA_MODULES = [
     'httpd', 'kadmin', 'dirsrv', 'pki-cad', 'pki-tomcatd', 'install',
diff --git a/ipaserver/install/ipa_ldap_updater.py b/ipaserver/install/ipa_ldap_updater.py
index 062bd5a4396f2d074986b3181efe9f04185ea8d2..90c09c48fed0df33e4e67b0347207b3ccc9fd72c 100644
--- a/ipaserver/install/ipa_ldap_updater.py
+++ b/ipaserver/install/ipa_ldap_updater.py
@@ -28,6 +28,8 @@
 import os
 import sys
 
+import six
+
 from ipalib import api
 from ipapython import ipautil, admintool
 from ipaplatform.paths import paths
@@ -35,6 +37,9 @@
 from ipaserver.install.ldapupdate import LDAPUpdate, UPDATES_DIR, BadSyntax
 from ipaserver.install.upgradeinstance import IPAUpgrade
 
+if six.PY3:
+    unicode = str
+
 
 class LDAPUpdater(admintool.AdminTool):
     command_name = 'ipa-ldap-updater'
diff --git a/ipaserver/install/ipa_otptoken_import.py b/ipaserver/install/ipa_otptoken_import.py
index 130e2ce51461c14a1af48c17ead2f5dd4d44ce63..6377c069686932080e6cf90076612f66745c67a1 100644
--- a/ipaserver/install/ipa_otptoken_import.py
+++ b/ipaserver/install/ipa_otptoken_import.py
@@ -38,6 +38,9 @@
 from ipalib import api, errors
 from ipaserver.plugins.ldap2 import ldap2
 
+if six.PY3:
+    unicode = str
+
 
 class ValidationError(Exception):
     pass
diff --git a/ipaserver/install/ipa_winsync_migrate.py b/ipaserver/install/ipa_winsync_migrate.py
index 75d1dbe315a8a8aa4f19497912f28108730b9caa..cafec9d188dbf2f1be07edea031d76f5e88dccbf 100644
--- a/ipaserver/install/ipa_winsync_migrate.py
+++ b/ipaserver/install/ipa_winsync_migrate.py
@@ -20,6 +20,8 @@
 import gssapi
 import sys
 
+import six
+
 from ipalib import api
 from ipalib import errors
 from ipapython import admintool
@@ -29,6 +31,9 @@
 from ipaserver.plugins.ldap2 import ldap2
 from ipaserver.install import replication
 
+if six.PY3:
+    unicode = str
+
 DEFAULT_TRUST_VIEW_NAME = u'Default Trust View'
 
 
diff --git a/ipaserver/install/plugins/rename_managed.py b/ipaserver/install/plugins/rename_managed.py
index 4b42d48dc55b877fd1408ca422d6fbd2351605fe..873c3ddb0b6fd177eecac6c9ab24c3f4b12f3bf4 100644
--- a/ipaserver/install/plugins/rename_managed.py
+++ b/ipaserver/install/plugins/rename_managed.py
@@ -17,11 +17,17 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import six
+
 from ipalib import api, errors
 from ipalib import Updater
 from ipapython import ipautil
 from ipapython.dn import DN
 
+if six.PY3:
+    unicode = str
+
+
 def entry_to_update(entry):
     """
     Convert an entry into a name/value pair list that looks like an update.
diff --git a/ipaserver/install/plugins/update_managed_permissions.py b/ipaserver/install/plugins/update_managed_permissions.py
index 79af64c38dc8560e96580ff6131a5a75d41bfca8..d68e24302edfcb5674c0cc654ba202eb8f650cc4 100644
--- a/ipaserver/install/plugins/update_managed_permissions.py
+++ b/ipaserver/install/plugins/update_managed_permissions.py
@@ -83,6 +83,8 @@
 The plugin also deletes permissions specified in OBSOLETE_PERMISSIONS.
 """
 
+import six
+
 from ipalib import api, errors
 from ipapython.dn import DN
 from ipalib.plugable import Registry
@@ -92,6 +94,9 @@
 from ipalib import Updater
 from ipapython import ipautil
 
+if six.PY3:
+    unicode = str
+
 register = Registry()
 
 OBSOLETE_PERMISSIONS = {
diff --git a/ipaserver/install/server/install.py b/ipaserver/install/server/install.py
index f9baa0757df488e7b15e6e60a368d822ed3cd063..ca9873c5cac4efa9ac54e24dd7517cab5915ddbf 100644
--- a/ipaserver/install/server/install.py
+++ b/ipaserver/install/server/install.py
@@ -13,6 +13,8 @@
 import tempfile
 import textwrap
 
+import six
+
 from ipapython import certmonger, dogtag, ipaldap, ipautil, sysrestore
 from ipapython.dn import DN
 from ipapython.install import common, core
@@ -38,6 +40,9 @@
     update_hosts_file)
 from ipaserver.plugins.ldap2 import ldap2
 
+if six.PY3:
+    unicode = str
+
 try:
     from ipaserver.install import adtrustinstance
     _server_trust_ad_installed = True
diff --git a/ipaserver/install/server/upgrade.py b/ipaserver/install/server/upgrade.py
index 093aee878be797b853202be8907598f4f9adaff1..68238de9f7a2add1c90b778986e8536cc1af3f00 100644
--- a/ipaserver/install/server/upgrade.py
+++ b/ipaserver/install/server/upgrade.py
@@ -12,6 +12,8 @@
 import ConfigParser
 import sys
 
+import six
+
 from ipalib import api
 import SSSDConfig
 import ipalib.util
@@ -39,6 +41,9 @@
 from ipaserver.install.upgradeinstance import IPAUpgrade
 from ipaserver.install.ldapupdate import BadSyntax
 
+if six.PY3:
+    unicode = str
+
 
 class KpasswdInstance(service.SimpleServiceInstance):
     def __init__(self):
diff --git a/ipaserver/plugins/dogtag.py b/ipaserver/plugins/dogtag.py
index 1b39c148c413ef8fb405b8e9b8c67829d8855fb9..1a4bf2eab2f1b2726959286df32b518f65be557e 100644
--- a/ipaserver/plugins/dogtag.py
+++ b/ipaserver/plugins/dogtag.py
@@ -250,6 +250,7 @@
 from pki.client import PKIConnection
 import pki.crypto as cryptoutil
 from pki.kra import KRAClient
+import six
 
 from ipalib import Backend
 from ipapython.dn import DN
@@ -258,6 +259,9 @@
 from ipapython import ipautil
 from ipaserver.install.certs import CertDB
 
+if six.PY3:
+    unicode = str
+
 # These are general status return values used when
 # CMSServlet.outputError() is invoked.
 CMS_SUCCESS      = 0
diff --git a/ipaserver/plugins/join.py b/ipaserver/plugins/join.py
index 7342117e78e3f82c78e0ef0aac8eea6a0b20fde9..cfa1354324c7de0c16f3218e0b6ea5daa69fdc8e 100644
--- a/ipaserver/plugins/join.py
+++ b/ipaserver/plugins/join.py
@@ -21,12 +21,17 @@
 Joining an IPA domain
 """
 
+import six
+
 from ipalib import api
 from ipalib import Command, Str
 from ipalib import errors
 from ipalib import _
 from ipaserver.install import installutils
 
+if six.PY3:
+    unicode = str
+
 
 def validate_host(ugettext, cn):
     """
diff --git a/ipaserver/rpcserver.py b/ipaserver/rpcserver.py
index 3b0fee534eba1d2b902df72c859253cfcbd053fe..298f8bab176f45cb0398420ef20296cd0cd8e649 100644
--- a/ipaserver/rpcserver.py
+++ b/ipaserver/rpcserver.py
@@ -36,6 +36,7 @@
 import ldap.controls
 from pyasn1.type import univ, namedtype
 from pyasn1.codec.ber import encoder
+import six
 
 from ipalib import plugable, errors
 from ipalib.capabilities import VERSION_WITHOUT_CAPABILITIES
@@ -62,6 +63,9 @@
 from ipapython.version import VERSION
 from ipalib.text import _
 
+if six.PY3:
+    unicode = str
+
 HTTP_STATUS_SUCCESS = '200 Success'
 HTTP_STATUS_SERVER_ERROR = '500 Internal Server Error'
 
diff --git a/ipatests/test_cmdline/test_cli.py b/ipatests/test_cmdline/test_cli.py
index 1a97608a4ce4f74da25b4bcb6a90384e1a3aa4e4..3ad07f7daccd2045b64e214912e6fbd5e41153b1 100644
--- a/ipatests/test_cmdline/test_cli.py
+++ b/ipatests/test_cmdline/test_cli.py
@@ -4,11 +4,15 @@
 import StringIO
 
 import nose
+import six
 
 from ipatests import util
 from ipalib import api, errors
 from ipapython.version import API_VERSION
 
+if six.PY3:
+    unicode = str
+
 
 class TestCLIParsing(object):
     """Tests that commandlines are correctly parsed to Command keyword args
diff --git a/ipatests/test_cmdline/test_help.py b/ipatests/test_cmdline/test_help.py
index 68684a9258636e102cf524bea9870a8792305e93..2c0db3288a5b93f7ad8235969f2822a325eca446 100644
--- a/ipatests/test_cmdline/test_help.py
+++ b/ipatests/test_cmdline/test_help.py
@@ -22,10 +22,14 @@
 import StringIO
 
 from nose.tools import assert_raises  # pylint: disable=E0611
+import six
 
 from ipalib import api, errors
 from ipalib.plugins.user import user_add
 
+if six.PY3:
+    unicode = str
+
 
 class CLITestContext(object):
     """Context manager that replaces stdout & stderr, and catches SystemExit
diff --git a/ipatests/test_ipalib/test_base.py b/ipatests/test_ipalib/test_base.py
index 265e118585862a5f3c77ba8092943d9d52dccecf..67a82aa92638d8f748fb681cc925da581d6ba192 100644
--- a/ipatests/test_ipalib/test_base.py
+++ b/ipatests/test_ipalib/test_base.py
@@ -21,11 +21,16 @@
 Test the `ipalib.base` module.
 """
 
+import six
+
 from ipatests.util import ClassChecker, raises
 from ipalib.constants import NAME_REGEX, NAME_ERROR
 from ipalib.constants import TYPE_ERROR, SET_ERROR, DEL_ERROR, OVERRIDE_ERROR
 from ipalib import base
 
+if six.PY3:
+    unicode = str
+
 
 class test_ReadOnly(ClassChecker):
     """
diff --git a/ipatests/test_ipalib/test_errors.py b/ipatests/test_ipalib/test_errors.py
index 83180060667e4fc36924e3950ff6e5c8617bf19f..8cc9cd27661ccc51e04c564d8e76291c0f43375b 100644
--- a/ipatests/test_ipalib/test_errors.py
+++ b/ipatests/test_ipalib/test_errors.py
@@ -27,11 +27,16 @@
 import re
 import inspect
 
+import six
+
 from ipatests.util import assert_equal, raises
 from ipalib import errors, text
 from ipaplatform.paths import paths
 from ipalib.constants import TYPE_ERROR
 
+if six.PY3:
+    unicode = str
+
 
 class PrivateExceptionTester(object):
     _klass = None
diff --git a/ipatests/test_ipalib/test_frontend.py b/ipatests/test_ipalib/test_frontend.py
index c74646dc10438c8c8e5ee8968fdfea1812cf9abb..d22718c8bad6e90d7dd1520c7a4ff03670fcddeb 100644
--- a/ipatests/test_ipalib/test_frontend.py
+++ b/ipatests/test_ipalib/test_frontend.py
@@ -24,6 +24,8 @@
 # FIXME: Pylint errors
 # pylint: disable=no-member
 
+import six
+
 from ipatests.util import raises, read_only
 from ipatests.util import ClassChecker, create_test_api
 from ipatests.util import assert_equal
@@ -34,6 +36,10 @@
 from ipalib.parameters import Str
 from ipapython.version import API_VERSION
 
+if six.PY3:
+    unicode = str
+
+
 def test_RULE_FLAG():
     assert frontend.RULE_FLAG == 'validation_rule'
 
diff --git a/ipatests/test_ipalib/test_parameters.py b/ipatests/test_ipalib/test_parameters.py
index e837bf8ec305056e836583b6c8f1b672773ca6b1..6b8fc1d946dee4b50c465d276b09a8195401f386 100644
--- a/ipatests/test_ipalib/test_parameters.py
+++ b/ipatests/test_ipalib/test_parameters.py
@@ -43,6 +43,9 @@
 from ipalib.errors import ValidationError, ConversionError
 from ipalib import _
 
+if six.PY3:
+    unicode = str
+
 NULLS = (None, '', u'', tuple(), [])
 
 class test_DefaultFrom(ClassChecker):
diff --git a/ipatests/test_ipalib/test_rpc.py b/ipatests/test_ipalib/test_rpc.py
index 5c130bdc698dbad3d2bec785fdda4a2057e19460..710d09832fa884234b85aa9305691bf2a14223dc 100644
--- a/ipatests/test_ipalib/test_rpc.py
+++ b/ipatests/test_ipalib/test_rpc.py
@@ -25,6 +25,8 @@
 from xmlrpclib import Binary, Fault, dumps, loads
 
 import nose
+import six
+
 from ipatests.util import raises, assert_equal, PluginTester, DummyClass
 from ipatests.data import binary_bytes, utf8_bytes, unicode_str
 from ipalib.frontend import Command
@@ -32,6 +34,9 @@
 from ipalib import rpc, errors, api, request
 from ipapython.version import API_VERSION
 
+if six.PY3:
+    unicode = str
+
 
 std_compound = (binary_bytes, utf8_bytes, unicode_str)
 
diff --git a/ipatests/test_ipalib/test_text.py b/ipatests/test_ipalib/test_text.py
index c6ab388876ec86d9f74cf31e477641971ae43186..195610d274765728142dec0b4b714d6b7a26611a 100644
--- a/ipatests/test_ipalib/test_text.py
+++ b/ipatests/test_ipalib/test_text.py
@@ -26,8 +26,11 @@
 import shutil
 import tempfile
 import re
+
 import nose
 import locale
+import six
+
 from ipatests.util import raises, assert_equal
 from ipatests.i18n import create_po, po_file_iterate
 from ipalib.request import context
@@ -35,6 +38,9 @@
 from ipalib import text
 from ipapython.ipautil import file_exists
 
+if six.PY3:
+    unicode = str
+
 singular = '%(count)d goose makes a %(dish)s'
 plural = '%(count)d geese make a %(dish)s'
 
diff --git a/ipatests/test_ipapython/test_dn.py b/ipatests/test_ipapython/test_dn.py
index 69ccbde8e7f767b6b943afc3169220d0a5821742..14aaeafb58033d5145f1a085b986cd9419b2675a 100644
--- a/ipatests/test_ipapython/test_dn.py
+++ b/ipatests/test_ipapython/test_dn.py
@@ -2,8 +2,13 @@
 
 import unittest
 
+import six
+
 from ipapython.dn import *
 
+if six.PY3:
+    unicode = str
+
 def expected_class(klass, component):
     if klass is AVA:
         if component == 'self':
diff --git a/ipatests/test_ipapython/test_ssh.py b/ipatests/test_ipapython/test_ssh.py
index 913ff8e6bacb606ecabf2a1d2a5f7a600c7f6f4c..9826a34c30240c0aca4bd0ca95f4adef3d68cd43 100644
--- a/ipatests/test_ipapython/test_ssh.py
+++ b/ipatests/test_ipapython/test_ssh.py
@@ -21,10 +21,16 @@
 """
 
 import base64
+
+import six
 import nose
 
 from ipapython import ssh
 
+if six.PY3:
+    unicode = str
+
+
 def make_public_key_checker(pk, out):
     def check_public_key():
         try:
diff --git a/ipatests/test_ipaserver/test_install/test_adtrustinstance.py b/ipatests/test_ipaserver/test_install/test_adtrustinstance.py
index 9a62f87ce55f846bcdccdb700e20e4221fc71dff..75e53f35e58402d5376791ba1bc127df1f8352c8 100755
--- a/ipatests/test_ipaserver/test_install/test_adtrustinstance.py
+++ b/ipatests/test_ipaserver/test_install/test_adtrustinstance.py
@@ -21,10 +21,15 @@
 """
 
 import os
+
+import six
 import nose
 
 from ipaserver.install import adtrustinstance
 
+if six.PY3:
+    unicode = str
+
 class test_adtrustinstance:
     """
     Test `adtrustinstance`.
diff --git a/ipatests/test_ipaserver/test_ldap.py b/ipatests/test_ipaserver/test_ldap.py
index f50c19a9238ab2f920f041b2ec50eaccce909d24..c3a9717c54696eac44f91a974ff7ad19a3dcf5d2 100644
--- a/ipatests/test_ipaserver/test_ldap.py
+++ b/ipatests/test_ipaserver/test_ldap.py
@@ -32,6 +32,7 @@
 import nose
 from nose.tools import assert_raises  # pylint: disable=E0611
 import nss.nss as nss
+import six
 
 from ipaserver.plugins.ldap2 import ldap2
 from ipalib.plugins.service import service, service_show
@@ -41,6 +42,9 @@
 from ipaplatform.paths import paths
 from ipapython.dn import DN
 
+if six.PY3:
+    unicode = str
+
 class test_ldap(object):
     """
     Test various LDAP client bind methods.
diff --git a/ipatests/test_ipaserver/test_rpcserver.py b/ipatests/test_ipaserver/test_rpcserver.py
index c77c2d97c8cf1a9f3188c40866f9a7a086af968d..95980eb05bc3030c5ece841acf41901b2c51e368 100644
--- a/ipatests/test_ipaserver/test_rpcserver.py
+++ b/ipatests/test_ipaserver/test_rpcserver.py
@@ -23,11 +23,16 @@
 
 import json
 
+import six
+
 from ipatests.util import create_test_api, assert_equal, raises, PluginTester
 from ipatests.data import unicode_str
 from ipalib import errors, Command
 from ipaserver import rpcserver
 
+if six.PY3:
+    unicode = str
+
 
 class StartResponse(object):
     def __init__(self):
diff --git a/ipatests/test_util.py b/ipatests/test_util.py
index ba72a25db28afe0eb3eaa6be475b1eb9b5964381..a0ee7384efedaf31e5dfdb8ba199f8b3d1aa34ea 100644
--- a/ipatests/test_util.py
+++ b/ipatests/test_util.py
@@ -23,9 +23,14 @@
 
 import re
 
+import six
+
 from ipatests import util
 from ipatests.util import raises, TYPE, VALUE, LEN, KEYS
 
+if six.PY3:
+    unicode = str
+
 
 class Prop(object):
     def __init__(self, *ops):
diff --git a/ipatests/test_xmlrpc/test_automount_plugin.py b/ipatests/test_xmlrpc/test_automount_plugin.py
index 952b29eecf39439392eae2d0b8aaaf56fd77b21e..dcc79c83c6e6828b0ce8250cfbb0aae73adf39c8 100644
--- a/ipatests/test_xmlrpc/test_automount_plugin.py
+++ b/ipatests/test_xmlrpc/test_automount_plugin.py
@@ -29,12 +29,16 @@
 from ipalib import api
 from ipalib import errors
 from ipapython.dn import DN
+import six
 
 from nose.tools import raises, assert_raises  # pylint: disable=E0611
 from ipatests.test_xmlrpc.xmlrpc_test import XMLRPC_test, assert_attr_equal
 from ipaplatform.paths import paths
 from ipatests.util import assert_deepequal
 
+if six.PY3:
+    unicode = str
+
 
 class MockTextui(list):
     """Collects output lines"""
diff --git a/ipatests/test_xmlrpc/test_cert_plugin.py b/ipatests/test_xmlrpc/test_cert_plugin.py
index 6c364763a372cf3eaa5be02f68745b28cddab985..a593db7f99559f0670fca715040b9d86870c3a2c 100644
--- a/ipatests/test_xmlrpc/test_cert_plugin.py
+++ b/ipatests/test_xmlrpc/test_cert_plugin.py
@@ -31,11 +31,15 @@
 from ipalib import x509
 import tempfile
 from ipapython import ipautil
+import six
 import nose
 import base64
 from ipaplatform.paths import paths
 from ipapython.dn import DN
 
+if six.PY3:
+    unicode = str
+
 # So we can save the cert from issuance and compare it later
 cert = None
 newcert = None
diff --git a/ipatests/test_xmlrpc/test_dns_realmdomains_integration.py b/ipatests/test_xmlrpc/test_dns_realmdomains_integration.py
index a8c224eec92c274b6de35fd10106ba0d925e2a9e..76d4a600b535ff58f17566e6040625d18533065c 100644
--- a/ipatests/test_xmlrpc/test_dns_realmdomains_integration.py
+++ b/ipatests/test_xmlrpc/test_dns_realmdomains_integration.py
@@ -22,6 +22,8 @@
 2. realmdomains_mod should add a _kerberos TXT record in the DNS zone.
 """
 
+import six
+
 from ipalib import api, errors
 from ipalib.util import normalize_zone
 from ipapython.dn import DN
@@ -29,6 +31,9 @@
 from ipatests.test_xmlrpc import objectclasses
 from ipatests.test_xmlrpc.xmlrpc_test import Declarative, fuzzy_digits
 
+if six.PY3:
+    unicode = str
+
 
 cn = u'Realm Domains'
 dn = DN(('cn', cn), ('cn', 'ipa'), ('cn', 'etc'), api.env.basedn)
diff --git a/ipatests/test_xmlrpc/test_idviews_plugin.py b/ipatests/test_xmlrpc/test_idviews_plugin.py
index 2823082b267ef5ab8c2136830109439897442e72..f1a46978b7324e83b0506084ff7a45e488005052 100644
--- a/ipatests/test_xmlrpc/test_idviews_plugin.py
+++ b/ipatests/test_xmlrpc/test_idviews_plugin.py
@@ -23,6 +23,8 @@
 
 import re
 
+import six
+
 from ipalib import api, errors
 from ipatests.test_xmlrpc import objectclasses
 from ipatests.test_xmlrpc.xmlrpc_test import (Declarative, uuid_re, add_oc,
@@ -32,6 +34,9 @@
 from ipatests.util import Fuzzy
 from ipapython.dn import DN
 
+if six.PY3:
+    unicode = str
+
 
 idview1 = u'idview1'
 idview2 = u'idview2'
diff --git a/ipatests/test_xmlrpc/test_radiusproxy_plugin.py b/ipatests/test_xmlrpc/test_radiusproxy_plugin.py
index beb0b8c389ff02b44ddba158b3e9995958794596..0767127771ccb79212dd889ccd45fa60b36e125d 100644
--- a/ipatests/test_xmlrpc/test_radiusproxy_plugin.py
+++ b/ipatests/test_xmlrpc/test_radiusproxy_plugin.py
@@ -18,12 +18,17 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
+import six
+
 from ipalib import errors, api, _
 from ipapython.dn import DN
 from ipatests.test_xmlrpc.xmlrpc_test import Declarative
 from ipatests.test_xmlrpc.test_user_plugin import get_user_result
 from ipatests.test_xmlrpc import objectclasses
 
+if six.PY3:
+    unicode = str
+
 radius1 = u'testradius'
 radius1_fqdn = u'testradius.test'
 radius1_dn = DN(('cn=testradius'), ('cn=radiusproxy'), api.env.basedn)
diff --git a/ipatests/test_xmlrpc/test_range_plugin.py b/ipatests/test_xmlrpc/test_range_plugin.py
index 143da96fd33b624207dd6d0f4411e1cbed52985e..29af35306df6eccf20157643ec6f5a96f2144358 100644
--- a/ipatests/test_xmlrpc/test_range_plugin.py
+++ b/ipatests/test_xmlrpc/test_range_plugin.py
@@ -21,6 +21,8 @@
 Test the `ipalib/plugins/idrange.py` module, and XML-RPC in general.
 """
 
+import six
+
 from ipalib import api, errors
 from ipatests.test_xmlrpc.xmlrpc_test import Declarative, fuzzy_uuid
 from ipatests.test_xmlrpc import objectclasses
@@ -28,6 +30,9 @@
 from ipapython.dn import DN
 from ipatests.test_xmlrpc.test_user_plugin import get_user_result
 
+if six.PY3:
+    unicode = str
+
 # Determine the test shift used
 
 id_shift = 0
diff --git a/ipatests/test_xmlrpc/test_stageuser_plugin.py b/ipatests/test_xmlrpc/test_stageuser_plugin.py
index 515191a45dad164139d4ed7f1bc245837c3550ee..b09ef6e84cd95a32061b07d833c5a39f1750f80b 100644
--- a/ipatests/test_xmlrpc/test_stageuser_plugin.py
+++ b/ipatests/test_xmlrpc/test_stageuser_plugin.py
@@ -13,6 +13,8 @@
 import functools
 import pytest
 
+import six
+
 from ipalib import api, errors
 
 from ipatests.test_xmlrpc.ldaptracker import Tracker
@@ -27,6 +29,9 @@
 from ipatests.test_xmlrpc.test_user_plugin import UserTracker, get_user_dn
 from ipatests.test_xmlrpc.test_group_plugin import GroupTracker
 
+if six.PY3:
+    unicode = str
+
 validuser1 = u'tuser1'
 validuser2 = u'tuser2'
 
diff --git a/ipatests/test_xmlrpc/test_sudorule_plugin.py b/ipatests/test_xmlrpc/test_sudorule_plugin.py
index cef0f45189c8fd0a47200291f022672571d3b660..7d8735c4925ae5630b0929dc1f5fc91d089fd23c 100644
--- a/ipatests/test_xmlrpc/test_sudorule_plugin.py
+++ b/ipatests/test_xmlrpc/test_sudorule_plugin.py
@@ -22,11 +22,16 @@
 """
 
 from nose.tools import raises, assert_raises  # pylint: disable=E0611
+import six
 
 from ipatests.test_xmlrpc.xmlrpc_test import XMLRPC_test, assert_attr_equal
 from ipalib import api
 from ipalib import errors
 
+if six.PY3:
+    unicode = str
+
+
 class test_sudorule(XMLRPC_test):
     """
     Test the `sudorule` plugin.
diff --git a/ipatests/test_xmlrpc/test_trust_plugin.py b/ipatests/test_xmlrpc/test_trust_plugin.py
index 5f2de59065d3d674031d4a21d791f98be31ab22f..b5f53a78d6cf93c114e3470c06a84a476df1d8ed 100644
--- a/ipatests/test_xmlrpc/test_trust_plugin.py
+++ b/ipatests/test_xmlrpc/test_trust_plugin.py
@@ -21,6 +21,8 @@
 """
 
 import nose
+import six
+
 from ipalib import api, errors
 from ipapython.dn import DN
 from ipatests.test_xmlrpc import objectclasses
@@ -28,6 +30,9 @@
     Declarative, fuzzy_guid, fuzzy_domain_sid, fuzzy_string, fuzzy_uuid,
     fuzzy_digits)
 
+if six.PY3:
+    unicode = str
+
 
 trustconfig_ad_config = DN(('cn', api.env.domain),
         api.env.container_cifsdomains, api.env.basedn)
diff --git a/ipatests/test_xmlrpc/testcert.py b/ipatests/test_xmlrpc/testcert.py
index b9a01118d86be818c2fd23efbe25cb3dd7242fc8..620879205cb72914a41172aa5416dad1c20e07c5 100644
--- a/ipatests/test_xmlrpc/testcert.py
+++ b/ipatests/test_xmlrpc/testcert.py
@@ -28,12 +28,17 @@
 import os
 import tempfile
 import shutil
+import six
+
 from ipalib import api, x509
 from ipaserver.plugins import rabase
 from ipapython import ipautil
 from ipaplatform.paths import paths
 from ipapython.dn import DN
 
+if six.PY3:
+    unicode = str
+
 
 def get_testcert(subject, principal):
     """Get the certificate, creating it if it doesn't exist"""
diff --git a/ipatests/util.py b/ipatests/util.py
index 5a6595a62b2fa677d3a6db98d18bc19cbd68a9c3..459d6776842e8244eb9ce493f5454e932b39ef15 100644
--- a/ipatests/util.py
+++ b/ipatests/util.py
@@ -38,6 +38,9 @@
 from ipalib.request import context
 from ipapython.dn import DN
 
+if six.PY3:
+    unicode = str
+
 
 class TempDir(object):
     def __init__(self):
-- 
2.1.0

From bd352b3708999fe8a23fc9d96916b98902f8ece7 Mon Sep 17 00:00:00 2001
From: Jan Cholasta <jchol...@redhat.com>
Date: Fri, 11 Sep 2015 14:02:13 +0200
Subject: [PATCH] Use bytes instead of str where appropriate

Under Python 2, "str" and "bytes" are synonyms.
---
 ipalib/cli.py                    |  4 ++--
 ipalib/parameters.py             |  8 ++++----
 ipalib/plugins/baseldap.py       |  4 ++--
 ipalib/rpc.py                    |  6 +++---
 ipapython/ipaldap.py             | 34 +++++++++++++++++-----------------
 ipatests/test_ipalib/test_rpc.py | 10 +++++-----
 6 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/ipalib/cli.py b/ipalib/cli.py
index 347d4c788c19ae3f2c23bda1094fe1691fa073da..b0e138925155f2547d6abb8f89d98b61f52cc318 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -141,7 +141,7 @@ def decode(self, value):
         """
         Decode text from stdin.
         """
-        if type(value) is str:
+        if type(value) is bytes:
             encoding = self.__get_encoding(sys.stdin)
             return value.decode(encoding)
         elif type(value) in (list, tuple):
@@ -166,7 +166,7 @@ def encode_binary(self, value):
         Convert a binary value to base64. We know a value is binary
         if it is a python str type, otherwise it is a plain string.
         """
-        if type(value) is str:
+        if type(value) is bytes:
             return base64.b64encode(value)
         elif type(value) is datetime.datetime:
             return value.strftime(LDAP_GENERALIZED_TIME_FORMAT)
diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index a03a75d83e6783f405012903a6b9c868b68e64d2..176df09ea89e4392feadb4e82bfe17d180836c2a 100644
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ -1333,7 +1333,7 @@ class Bytes(Data):
     Also see the `Str` parameter.
     """
 
-    type = str
+    type = bytes
     type_error = _('must be binary data')
 
     def __init__(self, name, *rules, **kw):
@@ -1348,7 +1348,7 @@ def _rule_minlength(self, _, value):
         """
         Check minlength constraint.
         """
-        assert type(value) is str
+        assert type(value) is bytes
         if len(value) < self.minlength:
             return _('must be at least %(minlength)d bytes') % dict(
                 minlength=self.minlength,
@@ -1358,7 +1358,7 @@ def _rule_maxlength(self, _, value):
         """
         Check maxlength constraint.
         """
-        assert type(value) is str
+        assert type(value) is bytes
         if len(value) > self.maxlength:
             return _('can be at most %(maxlength)d bytes') % dict(
                 maxlength=self.maxlength,
@@ -1368,7 +1368,7 @@ def _rule_length(self, _, value):
         """
         Check length constraint.
         """
-        assert type(value) is str
+        assert type(value) is bytes
         if len(value) != self.length:
             return _('must be exactly %(length)d bytes') % dict(
                 length=self.length,
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py
index 81fae151693d3188c8c5b7bebf97b13a20fcf319..4a02246474b0dc7ff9400b7b9bf29453b015a6b7 100644
--- a/ipalib/plugins/baseldap.py
+++ b/ipalib/plugins/baseldap.py
@@ -248,7 +248,7 @@ def entry_to_dict(entry, **options):
         for attr in entry:
             if attr.lower() == 'attributelevelrights':
                 value = entry[attr]
-            elif entry.conn.get_attribute_type(attr) is str:
+            elif entry.conn.get_attribute_type(attr) is bytes:
                 value = entry.raw[attr]
             else:
                 value = list(entry.raw[attr])
@@ -1082,7 +1082,7 @@ def process_attr_options(self, entry_attrs, dn, keys, options):
                     try:
                         entry_attrs[attr].remove(delval)
                     except ValueError:
-                        if isinstance(delval, str):
+                        if isinstance(delval, bytes):
                             # This is a Binary value, base64 encode it
                             delval = unicode(base64.b64encode(delval))
                         raise errors.AttrValueNotFound(attr=attr, value=delval)
diff --git a/ipalib/rpc.py b/ipalib/rpc.py
index 4d39503a76293a60af87b951b5a8990b8af51e8a..4d3914d6bf7cd56b55b7894532e2430da1cc0cc1 100644
--- a/ipalib/rpc.py
+++ b/ipalib/rpc.py
@@ -164,7 +164,7 @@ def xml_wrap(value, version):
         return dict(
             (k, xml_wrap(v, version)) for (k, v) in value.items()
         )
-    if type(value) is str:
+    if type(value) is bytes:
         return Binary(value)
     if type(value) is Decimal:
         # transfer Decimal as a string
@@ -221,7 +221,7 @@ def xml_unwrap(value, encoding='UTF-8'):
     if type(value) is str:
         return value.decode(encoding)
     if isinstance(value, Binary):
-        assert type(value.data) is str
+        assert type(value.data) is bytes
         return value.data
     if isinstance(value, DateTime):
         # xmlprc DateTime is converted to string of %Y%m%dT%H:%M:%S format
@@ -290,7 +290,7 @@ def json_encode_binary(val, version):
     elif isinstance(val, (list, tuple)):
         new_list = [json_encode_binary(v, version) for v in val]
         return new_list
-    elif isinstance(val, str):
+    elif isinstance(val, bytes):
         return {'__base64__': base64.b64encode(val)}
     elif isinstance(val, Decimal):
         return {'__base64__': base64.b64encode(str(val))}
diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py
index 9c78dbf69f49c75cc3065627e97b09b59a6889c2..e0ebabbfcaf24e49b2befee1ec98b7afe662b532 100644
--- a/ipapython/ipaldap.py
+++ b/ipapython/ipaldap.py
@@ -339,7 +339,7 @@ def _attr_name(self, name):
                 "attribute name must be unicode or str, got %s object %r" % (
                     name.__class__.__name__, name))
 
-        if isinstance(name, str):
+        if isinstance(name, bytes):
             name = name.decode('utf-8')
 
         return name
@@ -393,7 +393,7 @@ def _set_raw(self, name, value):
             raise TypeError("%s value must be list, got %s object %r" % (
                 name, value.__class__.__name__, value))
         for (i, item) in enumerate(value):
-            if not isinstance(item, str):
+            if not isinstance(item, bytes):
                 raise TypeError("%s[%d] value must be str, got %s object %r" % (
                     name, i, item.__class__.__name__, item))
 
@@ -619,19 +619,19 @@ class LDAPClient(object):
     SCOPE_SUBTREE = ldap.SCOPE_SUBTREE
 
     _SYNTAX_MAPPING = {
-        '1.3.6.1.4.1.1466.115.121.1.1'   : str, # ACI item
-        '1.3.6.1.4.1.1466.115.121.1.4'   : str, # Audio
-        '1.3.6.1.4.1.1466.115.121.1.5'   : str, # Binary
-        '1.3.6.1.4.1.1466.115.121.1.8'   : str, # Certificate
-        '1.3.6.1.4.1.1466.115.121.1.9'   : str, # Certificate List
-        '1.3.6.1.4.1.1466.115.121.1.10'  : str, # Certificate Pair
+        '1.3.6.1.4.1.1466.115.121.1.1'   : bytes, # ACI item
+        '1.3.6.1.4.1.1466.115.121.1.4'   : bytes, # Audio
+        '1.3.6.1.4.1.1466.115.121.1.5'   : bytes, # Binary
+        '1.3.6.1.4.1.1466.115.121.1.8'   : bytes, # Certificate
+        '1.3.6.1.4.1.1466.115.121.1.9'   : bytes, # Certificate List
+        '1.3.6.1.4.1.1466.115.121.1.10'  : bytes, # Certificate Pair
         '1.3.6.1.4.1.1466.115.121.1.12'  : DN,  # Distinguished Name
-        '1.3.6.1.4.1.1466.115.121.1.23'  : str, # Fax
+        '1.3.6.1.4.1.1466.115.121.1.23'  : bytes, # Fax
         '1.3.6.1.4.1.1466.115.121.1.24'  : datetime.datetime,
-        '1.3.6.1.4.1.1466.115.121.1.28'  : str, # JPEG
-        '1.3.6.1.4.1.1466.115.121.1.40'  : str, # OctetString (same as Binary)
-        '1.3.6.1.4.1.1466.115.121.1.49'  : str, # Supported Algorithm
-        '1.3.6.1.4.1.1466.115.121.1.51'  : str, # Teletext Terminal Identifier
+        '1.3.6.1.4.1.1466.115.121.1.28'  : bytes, # JPEG
+        '1.3.6.1.4.1.1466.115.121.1.40'  : bytes, # OctetString (same as Binary)
+        '1.3.6.1.4.1.1466.115.121.1.49'  : bytes, # Supported Algorithm
+        '1.3.6.1.4.1.1466.115.121.1.51'  : bytes, # Teletext Terminal Identifier
 
         '2.16.840.1.113730.3.8.3.3'      : DN,  # enrolledBy
         '2.16.840.1.113730.3.8.3.18'     : DN,  # managedBy
@@ -772,7 +772,7 @@ def _flush_schema(self):
 
     def get_attribute_type(self, name_or_oid):
         if not self._decode_attrs:
-            return str
+            return bytes
 
         if isinstance(name_or_oid, unicode):
             name_or_oid = name_or_oid.encode('utf-8')
@@ -837,7 +837,7 @@ def encode(self, val):
             return value_to_utf8(val)
         elif isinstance(val, DNSName):
             return val.to_text()
-        elif isinstance(val, str):
+        elif isinstance(val, bytes):
             return val
         elif isinstance(val, list):
             return [self.encode(m) for m in val]
@@ -857,10 +857,10 @@ def decode(self, val, attr):
         """
         Decode attribute value from LDAP representation (str).
         """
-        if isinstance(val, str):
+        if isinstance(val, bytes):
             target_type = self.get_attribute_type(attr)
             try:
-                if target_type is str:
+                if target_type is bytes:
                     return val
                 elif target_type is unicode:
                     return val.decode('utf-8')
diff --git a/ipatests/test_ipalib/test_rpc.py b/ipatests/test_ipalib/test_rpc.py
index 710d09832fa884234b85aa9305691bf2a14223dc..31ed73cd54a308cc6327a0f1451bee701cc57805 100644
--- a/ipatests/test_ipalib/test_rpc.py
+++ b/ipatests/test_ipalib/test_rpc.py
@@ -67,8 +67,8 @@ def test_round_trip():
     assert_equal(dump_n_load(unicode_str), unicode_str)
     assert_equal(dump_n_load(Binary(binary_bytes)).data, binary_bytes)
     assert isinstance(dump_n_load(Binary(binary_bytes)), Binary)
-    assert type(dump_n_load('hello')) is str
-    assert type(dump_n_load(u'hello')) is str
+    assert type(dump_n_load('hello')) is bytes
+    assert type(dump_n_load(u'hello')) is bytes
     assert_equal(dump_n_load(''), '')
     assert_equal(dump_n_load(u''), '')
     assert dump_n_load(None) is None
@@ -81,7 +81,7 @@ def test_round_trip():
     assert_equal(round_trip(utf8_bytes), utf8_bytes)
     assert_equal(round_trip(unicode_str), unicode_str)
     assert_equal(round_trip(binary_bytes), binary_bytes)
-    assert type(round_trip('hello')) is str
+    assert type(round_trip('hello')) is bytes
     assert type(round_trip(u'hello')) is unicode
     assert_equal(round_trip(''), '')
     assert_equal(round_trip(u''), u'')
@@ -116,13 +116,13 @@ def test_xml_unwrap():
     assert f([]) == tuple()
     assert f({}) == dict()
     value = f(Binary(utf8_bytes))
-    assert type(value) is str
+    assert type(value) is bytes
     assert value == utf8_bytes
     assert f(utf8_bytes) == unicode_str
     assert f(unicode_str) == unicode_str
     value = f([True, Binary('hello'), dict(one=1, two=utf8_bytes, three=None)])
     assert value == (True, 'hello', dict(one=1, two=unicode_str, three=None))
-    assert type(value[1]) is str
+    assert type(value[1]) is bytes
     assert type(value[2]['two']) is unicode
 
 
-- 
2.1.0

From f44830dceb865d1f8eed09e77d0bd91e8404dd66 Mon Sep 17 00:00:00 2001
From: Jan Cholasta <jchol...@redhat.com>
Date: Tue, 1 Sep 2015 13:22:04 +0200
Subject: [PATCH] Use byte literals where appropriate

---
 ipaserver/install/plugins/upload_cacrt.py    |  2 +-
 ipaserver/install/replication.py             | 12 ++++++------
 ipatests/data.py                             |  6 +++---
 ipatests/test_ipalib/test_parameters.py      |  4 ++--
 ipatests/test_ipalib/test_rpc.py             | 24 ++++++++++++------------
 ipatests/test_ipaserver/test_ldap.py         |  4 ++--
 ipatests/test_xmlrpc/test_baseldap_plugin.py |  4 ++--
 7 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/ipaserver/install/plugins/upload_cacrt.py b/ipaserver/install/plugins/upload_cacrt.py
index ddca4babaecd2b78c10b871f70614da56f705a38..dcb7fe74794aeaa6d8ad3aff9280e7b5a9016c41 100644
--- a/ipaserver/install/plugins/upload_cacrt.py
+++ b/ipaserver/install/plugins/upload_cacrt.py
@@ -87,7 +87,7 @@ def execute(self, **options):
                 entry.single_value['cACertificate;binary'] = ca_cert
                 ldap.add_entry(entry)
             else:
-                if '' in entry['cACertificate;binary']:
+                if b'' in entry['cACertificate;binary']:
                     entry.single_value['cACertificate;binary'] = ca_cert
                     ldap.update_entry(entry)
 
diff --git a/ipaserver/install/replication.py b/ipaserver/install/replication.py
index aa2edd1722d46637cdec461daf65188ec3ab196b..5f0cf57c0ceed9ed9aecff251f92279410c383f2 100644
--- a/ipaserver/install/replication.py
+++ b/ipaserver/install/replication.py
@@ -1260,7 +1260,7 @@ def replica_cleanup(self, replica, realm, force=False):
             sub = {'suffix': self.suffix, 'fqdn': replica}
             try:
                 entry.raw['aci'].remove(
-                    '(target = "ldap:///cn=*,cn=ca_renewal,cn=ipa,cn=etc,'
+                    b'(target = "ldap:///cn=*,cn=ca_renewal,cn=ipa,cn=etc,'
                     '%(suffix)s")(version 3.0; acl "Add CA Certificates for '
                     'renewals"; allow(add) userdn = "ldap:///fqdn=%(fqdn)s,'
                     'cn=computers,cn=accounts,%(suffix)s";)' % sub)
@@ -1268,7 +1268,7 @@ def replica_cleanup(self, replica, realm, force=False):
                 pass
             try:
                 entry.raw['aci'].remove(
-                    '(target = "ldap:///cn=*,cn=ca_renewal,cn=ipa,cn=etc,'
+                    b'(target = "ldap:///cn=*,cn=ca_renewal,cn=ipa,cn=etc,'
                     '%(suffix)s")(targetattr = "userCertificate")'
                     '(version 3.0; acl "Modify CA Certificates for renewals"; '
                     'allow(write) userdn = "ldap:///fqdn=%(fqdn)s,'
@@ -1277,7 +1277,7 @@ def replica_cleanup(self, replica, realm, force=False):
                 pass
             try:
                 entry.raw['aci'].remove(
-                    '(target = "ldap:///cn=CAcert,cn=ipa,cn=etc,%(suffix)s")'
+                    b'(target = "ldap:///cn=CAcert,cn=ipa,cn=etc,%(suffix)s")'
                     '(targetattr = cACertificate)(version 3.0; acl "Modify CA '
                     'Certificate"; allow (write) userdn = "ldap:///fqdn='
                     '%(fqdn)s,cn=computers,cn=accounts,%(suffix)s";)' % sub)
@@ -1305,7 +1305,7 @@ def replica_cleanup(self, replica, realm, force=False):
             sub = {'suffix': self.suffix, 'fqdn': replica}
             try:
                 entry.raw['aci'].remove(
-                    '(targetfilter = "(objectClass=nsContainer)")'
+                    b'(targetfilter = "(objectClass=nsContainer)")'
                     '(targetattr = "cn || objectClass || ipaConfigString")'
                     '(version 3.0; acl "Read IPA Masters"; allow (read, '
                     'search, compare) userdn = "ldap:///fqdn=%(fqdn)s,'
@@ -1314,7 +1314,7 @@ def replica_cleanup(self, replica, realm, force=False):
                 pass
             try:
                 entry.raw['aci'].remove(
-                    '(targetfilter = "(objectClass=nsContainer)")'
+                    b'(targetfilter = "(objectClass=nsContainer)")'
                     '(targetattr = "ipaConfigString")(version 3.0; acl '
                     '"Modify IPA Masters"; allow (write) userdn = '
                     '"ldap:///fqdn=%(fqdn)s,cn=computers,cn=accounts,'
@@ -1343,7 +1343,7 @@ def replica_cleanup(self, replica, realm, force=False):
             sub = {'suffix': self.suffix, 'fqdn': replica}
             try:
                 entry.raw['aci'].remove(
-                    '(targetfilter = "(&(objectClass=ipaCertificate)'
+                    b'(targetfilter = "(&(objectClass=ipaCertificate)'
                     '(ipaConfigString=ipaCA))")(targetattr = '
                     '"ipaCertIssuerSerial || cACertificate")(version 3.0; acl '
                     '"Modify CA Certificate Store Entry"; allow (write) '
diff --git a/ipatests/data.py b/ipatests/data.py
index 5abfffcfdb0665d06afdc26dcbda8408936ddc97..7fe2002c632c8e5505dce33bace51aa6b28e8395 100644
--- a/ipatests/data.py
+++ b/ipatests/data.py
@@ -25,12 +25,12 @@
 
 
 # A string that should have bytes 'x\00' through '\xff':
-binary_bytes = ''.join(struct.pack('B', d) for d in range(256))
-assert '\x00' in binary_bytes and '\xff' in binary_bytes
+binary_bytes = b''.join(struct.pack('B', d) for d in range(256))
+assert b'\x00' in binary_bytes and b'\xff' in binary_bytes
 assert type(binary_bytes) is str and len(binary_bytes) == 256
 
 # A UTF-8 encoded str:
-utf8_bytes = '\xd0\x9f\xd0\xb0\xd0\xb2\xd0\xb5\xd0\xbb'
+utf8_bytes = b'\xd0\x9f\xd0\xb0\xd0\xb2\xd0\xb5\xd0\xbb'
 
 # The same UTF-8 data decoded (a unicode instance):
 unicode_str = u'\u041f\u0430\u0432\u0435\u043b'
diff --git a/ipatests/test_ipalib/test_parameters.py b/ipatests/test_ipalib/test_parameters.py
index 6b8fc1d946dee4b50c465d276b09a8195401f386..929289258ca2ff02f78900bfcc91d701ab276898 100644
--- a/ipatests/test_ipalib/test_parameters.py
+++ b/ipatests/test_ipalib/test_parameters.py
@@ -46,7 +46,7 @@
 if six.PY3:
     unicode = str
 
-NULLS = (None, '', u'', tuple(), [])
+NULLS = (None, b'', u'', tuple(), [])
 
 class test_DefaultFrom(ClassChecker):
     """
@@ -1636,4 +1636,4 @@ def test_init(self):
                       u'1991-31-12Z',
                       u'1991-12-07T25:30:05Z',
             ):
-            raises(ConversionError, o.convert, value)
\ No newline at end of file
+            raises(ConversionError, o.convert, value)
diff --git a/ipatests/test_ipalib/test_rpc.py b/ipatests/test_ipalib/test_rpc.py
index 31ed73cd54a308cc6327a0f1451bee701cc57805..1d3f33addfba5e8ba567f6e37057ed6f862bbe52 100644
--- a/ipatests/test_ipalib/test_rpc.py
+++ b/ipatests/test_ipalib/test_rpc.py
@@ -67,10 +67,10 @@ def test_round_trip():
     assert_equal(dump_n_load(unicode_str), unicode_str)
     assert_equal(dump_n_load(Binary(binary_bytes)).data, binary_bytes)
     assert isinstance(dump_n_load(Binary(binary_bytes)), Binary)
-    assert type(dump_n_load('hello')) is bytes
+    assert type(dump_n_load(b'hello')) is bytes
     assert type(dump_n_load(u'hello')) is bytes
-    assert_equal(dump_n_load(''), '')
-    assert_equal(dump_n_load(u''), '')
+    assert_equal(dump_n_load(b''), b'')
+    assert_equal(dump_n_load(u''), b'')
     assert dump_n_load(None) is None
 
     # Now we test our wrap and unwrap methods in combination with dumps, loads:
@@ -81,9 +81,9 @@ def test_round_trip():
     assert_equal(round_trip(utf8_bytes), utf8_bytes)
     assert_equal(round_trip(unicode_str), unicode_str)
     assert_equal(round_trip(binary_bytes), binary_bytes)
-    assert type(round_trip('hello')) is bytes
+    assert type(round_trip(b'hello')) is bytes
     assert type(round_trip(u'hello')) is unicode
-    assert_equal(round_trip(''), '')
+    assert_equal(round_trip(b''), b'')
     assert_equal(round_trip(u''), u'')
     assert round_trip(None) is None
     compound = [utf8_bytes, None, binary_bytes, (None, unicode_str),
@@ -99,13 +99,13 @@ def test_xml_wrap():
     f = rpc.xml_wrap
     assert f([], API_VERSION) == tuple()
     assert f({}, API_VERSION) == dict()
-    b = f('hello', API_VERSION)
+    b = f(b'hello', API_VERSION)
     assert isinstance(b, Binary)
-    assert b.data == 'hello'
+    assert b.data == b'hello'
     u = f(u'hello', API_VERSION)
     assert type(u) is unicode
     assert u == u'hello'
-    value = f([dict(one=False, two=u'hello'), None, 'hello'], API_VERSION)
+    value = f([dict(one=False, two=u'hello'), None, b'hello'], API_VERSION)
 
 
 def test_xml_unwrap():
@@ -120,8 +120,8 @@ def test_xml_unwrap():
     assert value == utf8_bytes
     assert f(utf8_bytes) == unicode_str
     assert f(unicode_str) == unicode_str
-    value = f([True, Binary('hello'), dict(one=1, two=utf8_bytes, three=None)])
-    assert value == (True, 'hello', dict(one=1, two=unicode_str, three=None))
+    value = f([True, Binary(b'hello'), dict(one=1, two=utf8_bytes, three=None)])
+    assert value == (True, b'hello', dict(one=1, two=unicode_str, three=None))
     assert type(value[1]) is bytes
     assert type(value[2]['two']) is unicode
 
@@ -134,7 +134,7 @@ def test_xml_dumps():
     params = (binary_bytes, utf8_bytes, unicode_str, None)
 
     # Test serializing an RPC request:
-    data = f(params, API_VERSION, 'the_method')
+    data = f(params, API_VERSION, b'the_method')
     (p, m) = loads(data)
     assert_equal(m, u'the_method')
     assert type(p) is tuple
@@ -165,7 +165,7 @@ def test_xml_loads():
     wrapped = rpc.xml_wrap(params, API_VERSION)
 
     # Test un-serializing an RPC request:
-    data = dumps(wrapped, 'the_method', allow_none=True)
+    data = dumps(wrapped, b'the_method', allow_none=True)
     (p, m) = f(data)
     assert_equal(m, u'the_method')
     assert_equal(p, params)
diff --git a/ipatests/test_ipaserver/test_ldap.py b/ipatests/test_ipaserver/test_ldap.py
index c3a9717c54696eac44f91a974ff7ad19a3dcf5d2..47d37c9bff940477ca2640106c8ec1f5573b715f 100644
--- a/ipatests/test_ipaserver/test_ldap.py
+++ b/ipatests/test_ipaserver/test_ldap.py
@@ -306,7 +306,7 @@ def test_sync(self):
         assert nice == [2, 3, u'5']
         assert raw == ['3', '5', '2']
 
-        raw = ['a', 'b']
+        raw = [b'a', b'b']
         e.raw['test'] = raw
         assert e['test'] is not nice
         assert e['test'] == [u'a', u'b']
@@ -314,7 +314,7 @@ def test_sync(self):
         nice = 'not list'
         e['test'] = nice
         assert e['test'] is nice
-        assert e.raw['test'] == ['not list']
+        assert e.raw['test'] == [b'not list']
 
         e.raw['test'].append('second')
         assert e['test'] == ['not list', u'second']
diff --git a/ipatests/test_xmlrpc/test_baseldap_plugin.py b/ipatests/test_xmlrpc/test_baseldap_plugin.py
index 6da56262b7bff241063409ec6c809033ac7afa65..477772c00731a3ace48da21d4c72c9174c987093 100644
--- a/ipatests/test_xmlrpc/test_baseldap_plugin.py
+++ b/ipatests/test_xmlrpc/test_baseldap_plugin.py
@@ -201,13 +201,13 @@ def __init__(self):
         DN('cn=test'),
         textattr=[u'text'],
         dnattr=[DN('cn=test')],
-        binaryattr=['\xffabcd'],
+        binaryattr=[b'\xffabcd'],
         attributelevelrights=rights)
     the_dict = {
         u'dn': u'cn=test',
         u'textattr': [u'text'],
         u'dnattr': [u'cn=test'],
-        u'binaryattr': ['\xffabcd'],
+        u'binaryattr': [b'\xffabcd'],
         u'attributelevelrights': rights}
     assert_deepequal(
         baseldap.entry_to_dict(entry, all=True, raw=True),
-- 
2.1.0

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to