fix: honour a falsey key in all_unique
all_unique applied the key with `map(key, iterable) if key else iterable`, so a falsey callable was silently ignored. it now checks `key is not None` like the other key functions, same fix as #1309.
This commit is contained in:
1 parent
d1d5e24692
commit
8780c614af
3 files changed
+15
-1
No files matched your search
@@ -4279,7 +4279,7 @@ def all_unique(iterable, key=None):
|
||||
seenset_add = seenset.add
|
||||
seenlist = []
|
||||
seenlist_add = seenlist.append
|
||||
for element in map(key, iterable) if key else iterable:
|
||||
for element in map(key, iterable) if key is not None else iterable:
|
||||
try:
|
||||
if element in seenset:
|
||||
return False
|
||||
|
||||
Reference in new issue
Block a user