Skip to content

Commit fe12e62

Browse files
authored
Python: Avoid clobbering range in test
This was an unwanted interaction between two unrelated tests, so I switched to a different built-in in the second test. I also added a test case that shows an unfortunate side effect of this more restricted handling of built-ins.
1 parent ff2b6b9 commit fe12e62

File tree

1 file changed

+12
-8
lines changed
  • python/ql/test/experimental/dataflow/ApiGraphs

1 file changed

+12
-8
lines changed

python/ql/test/experimental/dataflow/ApiGraphs/test.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,18 @@ def my_print(x):
122122
print = my_print
123123
print("these words")
124124

125-
def local_redefine_range():
126-
range = 5
127-
return range
128-
129-
def global_redefine_range():
130-
global range
131-
range = 6
132-
return range #$ SPURIOUS: use=moduleImport("builtins").getMember("range")
125+
def local_redefine_chr():
126+
chr = 5
127+
return chr
128+
129+
def global_redefine_chr():
130+
global chr
131+
chr = 6
132+
return chr
133+
134+
def what_is_chr_now():
135+
# If global_redefine_chr has been run, then the following is _not_ a reference to the built-in chr
136+
return chr(123) #$ MISSING: use=moduleImport("builtins").getMember("chr").getReturn()
133137

134138
def obscured_print():
135139
p = print #$ use=moduleImport("builtins").getMember("print")

0 commit comments

Comments
 (0)