From 1514852193ceb0db66f5290d3953873bd26f80f7 Mon Sep 17 00:00:00 2001 From: stroeder Date: Sat, 18 Nov 2017 20:08:02 +0000 Subject: [PATCH] ldap.async: avoid using .has_key() and check result types against set() instances --- Lib/ldap/async.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/Lib/ldap/async.py b/Lib/ldap/async.py index 81824e4..7f3d7c3 100644 --- a/Lib/ldap/async.py +++ b/Lib/ldap/async.py @@ -11,17 +11,16 @@ from ldap import __version__ +SEARCH_RESULT_TYPES = set([ + ldap.RES_SEARCH_ENTRY, + ldap.RES_SEARCH_RESULT, + ldap.RES_SEARCH_REFERENCE, +]) -_searchResultTypes={ - ldap.RES_SEARCH_ENTRY:None, - ldap.RES_SEARCH_RESULT:None, - ldap.RES_SEARCH_REFERENCE:None, -} - -_entryResultTypes={ - ldap.RES_SEARCH_ENTRY:None, - ldap.RES_SEARCH_RESULT:None, -} +ENTRY_RESULT_TYPES = set([ + ldap.RES_SEARCH_ENTRY, + ldap.RES_SEARCH_RESULT, +]) class WrongResultType(Exception): @@ -137,8 +136,8 @@ def processResults(self,ignoreResultsNumber=0,processResultsCount=0,timeout=-1): self._afterFirstResult = 0 if not result_list: break - if not _searchResultTypes.has_key(result_type): - raise WrongResultType(result_type,_searchResultTypes.keys()) + if result_type not in SEARCH_RESULT_TYPES: + raise WrongResultType(result_type,SEARCH_RESULT_TYPES) # Loop over list of search results for result_item in result_list: if result_counter