Skip to content

Commit

Permalink
Raise TypeError when a group is indexed with None
Browse files Browse the repository at this point in the history
Fixes #3092
  • Loading branch information
jbarnoud committed Feb 3, 2022
1 parent 2ecd5ed commit c7f701b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion package/MDAnalysis/core/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,9 @@ def __getitem__(self, item):
# because our _ix attribute is a numpy array
# it can be sliced by all of these already,
# so just return ourselves sliced by the item
if isinstance(item, numbers.Integral):
if item is None:
raise TypeError('None cannot be used to index a group.')
elif isinstance(item, numbers.Integral):
return self.level.singular(self.ix[item], self.universe)
else:
if isinstance(item, list) and item: # check for empty list
Expand Down

0 comments on commit c7f701b

Please sign in to comment.