Skip to content

Latest commit

 

History

History
25 lines (15 loc) · 765 Bytes

eval-used.md

File metadata and controls

25 lines (15 loc) · 765 Bytes

Pattern: Use of eval()

Issue: -

Description

Used when you use the eval() function, to discourage its usage. It's usage may have negative readability, performance and security implications, especially if you accept strings from untrusted or unknown sources. Consider using ast.literal_eval() for safely evaluating strings containing expressions from untrusted sources.

Example of incorrect code:

eval('os.listdir(".")')

Example of correct code:

ast.literal_eval('os.listdir(".")')

Further Reading