summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2020-12-04 10:10:50 +1300
committerNoel Power <npower@samba.org>2020-12-09 16:00:39 +0000
commit99cdb2191e9ab633579f4e7951c2da042529b95d (patch)
treea0f64cadc88a61af89cb3a743f953641b8480589 /python
parent713117401c85642dfa9de0772f0a9954a8b8d804 (diff)
downloadsamba-99cdb2191e9ab633579f4e7951c2da042529b95d.tar.gz
dbcheck: drop py2 support from dump_attr_values()
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
Diffstat (limited to 'python')
-rw-r--r--python/samba/dbchecker.py23
1 files changed, 9 insertions, 14 deletions
diff --git a/python/samba/dbchecker.py b/python/samba/dbchecker.py
index 6d16e88868e..3750b7bb45f 100644
--- a/python/samba/dbchecker.py
+++ b/python/samba/dbchecker.py
@@ -35,25 +35,20 @@ from samba.auth import system_session, admin_session
from samba.netcmd import CommandError
from samba.netcmd.fsmo import get_fsmo_roleowner
-# vals is a sequence of ldb.bytes objects which are a subclass
-# of 'byte' type in python3 and just a str type in python2, to
-# display as string these need to be converted to string via (str)
-# function in python3 but that may generate a UnicodeDecode error,
-# if so use repr instead. We need to at least try to get the 'str'
-# value if possible to allow some tests which check the strings
-# outputted to pass, these tests compare attr values logged to stdout
-# against those in various results files.
def dump_attr_values(vals):
- result = ""
+ """Stringify a value list, using utf-8 if possible (which some tests
+ want), or the python bytes representation otherwise (with leading
+ 'b' and escapes like b'\x00').
+ """
+ result = []
for value in vals:
- if len(result):
- result = "," + result
try:
- result = result + str(value)
+ result.append(value.decode('utf-8'))
except UnicodeDecodeError:
- result = result + repr(value)
- return result
+ result.append(repr(value))
+ return ','.join(result)
+
class dbcheck(object):
"""check a SAM database for errors"""