◐ Shell
reader mode source ↗
Skip to content
Merged
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
3 changes: 2 additions & 1 deletion quantities/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def __init__(self):
def __getitem__(self, string):
# This approach to avoiding arbitrary evaluation of code is based on https://stackoverflow.com/a/11952618
# by https://stackoverflow.com/users/567292/ecatmur
tree = ast.parse(string, mode="eval")
valid = all(isinstance(node, self.whitelist) for node in ast.walk(tree))
if valid:
try:
Expand Down
Toggle all file notes Toggle all file annotations