From 19c279184ca126a270e1d06c14d5fce5f8a0236e Mon Sep 17 00:00:00 2001 From: William Brown Date: Mon, 31 Oct 2016 14:03:59 +1000 Subject: [PATCH] Ticket 48961 - Fix lib389 minor issues shown by 48961 test Bug Description: There were a small number of issues in lib389. Mainly in reporting of errors with replication and how we deleted values. Fix Description: Fix the detection of a None to modify_s so that we can delete values. Fix error message for replication. https://fedorahosted.org/389/ticket/48961 Author: wibrown Review by: ??? --- lib389/__init__.py | 3 +-- lib389/_mapped_object.py | 2 +- lib389/utils.py | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib389/__init__.py b/lib389/__init__.py index 554b92a..868c547 100644 --- a/lib389/__init__.py +++ b/lib389/__init__.py @@ -2208,8 +2208,7 @@ class DirSrv(SimpleLDAPObject): replicated = True break except ldap.LDAPError as e: - log.fatal('testReplication() failed to modify (%s),' + - ' error (%s)' % (suffix, str(e))) + log.fatal('testReplication() failed to modify (%s), error (%s)' % (suffix, str(e))) return False loop += 1 time.sleep(2) diff --git a/lib389/_mapped_object.py b/lib389/_mapped_object.py index 88da0c8..039ce78 100644 --- a/lib389/_mapped_object.py +++ b/lib389/_mapped_object.py @@ -146,7 +146,7 @@ class DSLdapObject(DSLogging): if isinstance(value, list): # value = map(lambda x: ensure_bytes(x), value) value = ensure_list_bytes(value) - else: + elif value is not None: value = [ensure_bytes(value)] if self._batch: diff --git a/lib389/utils.py b/lib389/utils.py index cbb2ade..12b44ff 100644 --- a/lib389/utils.py +++ b/lib389/utils.py @@ -773,13 +773,13 @@ def socket_check_open(host, port): def ensure_bytes(val): - if MAJOR >= 3 and type(val) != bytes: + if MAJOR >= 3 and val != None and type(val) != bytes: return val.encode() return val def ensure_str(val): - if MAJOR >= 3 and type(val) != str: + if MAJOR >= 3 and val != None and type(val) != str: return val.decode('utf-8') return val -- 1.8.3.1