From a06267f2cc9a8fc57c2031d2023ba858dbebcac8 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Mon, 27 Nov 2017 16:59:14 +0100 Subject: [PATCH] Lib: Avoid eval() for getting module-level variables This is for compatibility with other libraries that inject extra variables, like unit testing with pytest. Based on a suggestion by AlanCoding: https://github.com/python-ldap/python-ldap/pull/25 --- Lib/ldap/schema/subentry.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib/ldap/schema/subentry.py b/Lib/ldap/schema/subentry.py index 2a42b4c..1c10d21 100644 --- a/Lib/ldap/schema/subentry.py +++ b/Lib/ldap/schema/subentry.py @@ -11,8 +11,7 @@ SCHEMA_CLASS_MAPPING = ldap.cidict.cidict() SCHEMA_ATTR_MAPPING = {} -for _name in dir(): - o = eval(_name) +for o in list(vars().values()): if hasattr(o,'schema_attribute'): SCHEMA_CLASS_MAPPING[o.schema_attribute] = o SCHEMA_ATTR_MAPPING[o] = o.schema_attribute