Skip to content

Commit 5fc056b

Browse files
Add regression test for false positive result.
1 parent 28261d6 commit 5fc056b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

python/ql/test/query-tests/Expressions/general/expressions_test.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,21 @@ def not_dup_key():
216216
u"😆" : 3
217217
}
218218

219+
# Lookup of unhashable object triggers TypeError, but the
220+
# exception is caught, so it's not a bug. This used to be
221+
# a false positive of the HashedButNoHash query.
222+
def func():
223+
unhash = list()
224+
try:
225+
hash(unhash)
226+
except TypeError:
227+
return 1
228+
return 0
229+
230+
def func():
231+
mapping = dict(); unhash = list()
232+
try:
233+
mapping[unhash]
234+
except TypeError:
235+
return 1
236+
return 0

0 commit comments

Comments
 (0)