Skip to content

Commit 5c9e460

Browse files
committed
Try to make the utils/listop functions return something sensible with empty input.
- Legacy-Id: 233
1 parent 47a88da commit 5c9e460

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

ietf/utils/listop.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@
33
def orl(list):
44
""" Return the "or" of every element in a list.
55
Used to generate "or" queries with a list of Q objects. """
6-
return reduce(operator.__or__, list)
7-
6+
if list:
7+
return reduce(operator.__or__, list)
8+
else:
9+
return None
10+
811
def flattenl(list):
912
""" Flatten a list one level, e.g., turn
1013
[ ['a'], ['b'], ['c', 'd'] ] into
1114
[ 'a', 'b', 'c', 'd' ]
1215
"""
13-
return reduce(operator.__concat__, list)
16+
if list:
17+
return reduce(operator.__concat__, list)
18+
else:
19+
return []

0 commit comments

Comments
 (0)