Skip to content

Commit

Permalink
Lib: Avoid eval() for getting module-level variables
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Petr Viktorin committed Nov 27, 2017
1 parent 4431a30 commit a06267f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions Lib/ldap/schema/subentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a06267f

Please sign in to comment.