We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bb3bdda commit 6cfe737Copy full SHA for 6cfe737
tests/basics/builtin_exec.py
@@ -4,3 +4,29 @@
4
d = {}
5
exec("def bar(): return 84", d)
6
print(d["bar"]())
7
+
8
+# passing None/dict as args to globals/locals
9
+foo = 11
10
+exec('print(foo)')
11
+exec('print(foo)', None)
12
+exec('print(foo)', {'foo':3}, None)
13
+exec('print(foo)', None, {'foo':3})
14
+exec('print(foo)', None, {'bar':3})
15
+exec('print(foo)', {'bar':3}, locals())
16
17
+try:
18
+ exec('print(foo)', {'bar':3}, None)
19
+except NameError:
20
+ print('NameError')
21
22
+# invalid arg passed to globals
23
24
+ exec('print(1)', 'foo')
25
+except TypeError:
26
+ print('TypeError')
27
28
+# invalid arg passed to locals
29
30
+ exec('print(1)', None, 123)
31
32
0 commit comments