fix byte-array / str

python3 returns byte-arrays instead of strings for ldap-data in
ContextCSNs, which makes the listcomprehension fail with a TypeError
when using the --serverID flag like so:

    CSN = [s for s in contextCSNs if sub in s]
TypeError: a bytes-like object is required, not 'str'

explicitly encoding 'sub' to byte-array, not sure if this is best way,
but seems to work well enough.
This commit is contained in:
Björn Zettergren 2021-03-19 16:14:34 +01:00 committed by Benjamin Renard
parent 5ce72df6dc
commit 2f6d97f761

View file

@ -323,7 +323,7 @@ class LdapServer(object):
if serverid is False:
return contextCSNs[0]
csnid = str(format(serverid, 'X')).zfill(3)
sub = '#%s#' % csnid
sub = str.encode('#%s#' % csnid, encoding="ascii", errors="replace")
CSN = [s for s in contextCSNs if sub in s]
if not CSN:
logging.error(