python/samba: port some isinstance str checks (to cater for unicode)
authorNoel Power <noel.power@suse.com>
Thu, 26 Apr 2018 09:38:57 +0000 (10:38 +0100)
committerNoel Power <npower@samba.org>
Mon, 30 Apr 2018 13:43:19 +0000 (15:43 +0200)
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
python/samba/__init__.py
python/samba/ms_schema.py

index f62f5e3920263a9eb88e791d6fcb9c685c66c4b2..20c7db2bc6c7c09bf90e1818871e3e44b3b12839 100644 (file)
@@ -29,6 +29,7 @@ import ldb
 import samba.param
 from samba import _glue
 from samba._ldb import Ldb as _Ldb
+from samba.compat import string_types
 
 
 def source_tree_topdir():
@@ -249,8 +250,8 @@ def substitute_var(text, values):
     """
 
     for (name, value) in values.items():
-        assert isinstance(name, str), "%r is not a string" % name
-        assert isinstance(value, str), "Value %r for %s is not a string" % (value, name)
+        assert isinstance(name, string_types), "%r is not a string" % name
+        assert isinstance(value, string_types), "Value %r for %s is not a string" % (value, name)
         text = text.replace("${%s}" % name, value)
 
     return text
index 889b7f5ef22940d7acdf9c88b1938bc63e77f2bb..de6e4b28cdc04a2d87f47471fba2930f3d8d9a63 100644 (file)
@@ -21,6 +21,7 @@ from __future__ import print_function
 import re
 import base64
 import uuid
+from samba.compat import string_types
 
 bitFields = {}
 
@@ -172,7 +173,7 @@ def fix_dn(dn):
 
 def __convert_bitfield(key, value):
     """Evaluate the OR expression in 'value'"""
-    assert(isinstance(value, str))
+    assert(isinstance(value, string_types))
 
     value = value.replace("\n ", "")
     value = value.replace(" ", "")
@@ -194,7 +195,7 @@ def __write_ldif_one(entry):
     out = []
 
     for l in entry:
-        if isinstance(l[1], str):
+        if isinstance(l[1], string_types):
             vl = [l[1]]
         else:
             vl = l[1]
@@ -247,7 +248,7 @@ def __transform_entry(entry, objectClass):
                 l[1] = oMObjectClassBER[l[1].strip()]
                 l[2] = True
 
-        if isinstance(l[1], str):
+        if isinstance(l[1], string_types):
             l[1] = fix_dn(l[1])
 
         if key == 'dn':