Руслан Касимов, 524 группа SafeEval 12412 | Шагов Виталий 521 SafeEval 12396 | ||||
---|---|---|---|---|---|
n | 1 | def safeval(st, g=globals(), l=None): | n | 1 | def safeval(kek, globs=globals(), locs=None): |
2 | if type(g) is dict: | 2 | if type(globs) == dict: | ||
3 | g = g.copy() | 3 | globs = globs.copy() | ||
4 | try: | 4 | try: | ||
n | 5 | return eval(st, g) | n | 5 | return eval(kek, globs) |
6 | except NameError: | 6 | except NameError: | ||
t | 7 | return st | t | 7 | return kek |
8 | except Exception as e: | 8 | except Exception as e: | ||
9 | return e | 9 | return e |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|