Merge pull request #781 from kevinbackhouse/HashedButNoHash

Python: fix false positive result.
This commit is contained in:
Mark Shannon
2019-01-18 21:56:12 +00:00
committed by GitHub
2 changed files with 44 additions and 5 deletions

View File

@@ -216,3 +216,21 @@ def not_dup_key():
u"😆" : 3
}
# Lookup of unhashable object triggers TypeError, but the
# exception is caught, so it's not a bug. This used to be
# a false positive of the HashedButNoHash query.
def func():
unhash = list()
try:
hash(unhash)
except TypeError:
return 1
return 0
def func():
mapping = dict(); unhash = list()
try:
mapping[unhash]
except TypeError:
return 1
return 0