From 1e7dafe4afc5ae953968bbffd1416e01f4f92229 Mon Sep 17 00:00:00 2001 From: William Brown Date: Thu, 7 Jan 2016 10:27:48 +1000 Subject: [PATCH] Ticket 48401 - lib389 Entry hasAttr returs dict instead of false Bug Description: If the search is highly targeted, and self.data in Entry is {}, hasAttr returns {} instead of False. Fix Description: The error is in the one line return function. We alter this to be more paranoid to ensure that we are returning the correct result. https://fedorahosted.org/389/ticket/48401 Author: wibrown Review by: ??? --- lib389/_entry.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib389/_entry.py b/lib389/_entry.py index e30b4e5..f2335b1 100644 --- a/lib389/_entry.py +++ b/lib389/_entry.py @@ -11,6 +11,7 @@ import six import logging import ldif import ldap +import collections from ldap.cidict import cidict from lib389._constants import * @@ -59,6 +60,7 @@ class Entry(object): If creating a new empty entry, data is the string DN. """ self.ref = None + self.data = None if entrydata: if isinstance(entrydata, tuple): if entrydata[0] is None: @@ -123,7 +125,10 @@ class Entry(object): """ Return True if this entry has an attribute named name, False otherwise """ - return self.data and name in self.data + if self.data is None or not isinstance(self.data, collections.Mapping): + # Perhaps this should be an exception? + return False + return name in self.data def __getattr__(self, name): """ -- 2.5.0