Delay error in users.get until after the end of the loop

This was originally done so that we wouldn't need to iterate through the (presumably large) set of users. However, when this raises, we have no idea which users actually match the criterias. By waiting until after, the traceback will actually print off the list of all potential users.
This commit is contained in:
Vgr E. Barry 2016-11-24 16:29:58 -05:00
parent 21b8ffa342
commit 5f50096d08

View File

@ -64,12 +64,13 @@ def _get(nick=None, ident=None, host=None, realname=None, account=None, *, allow
for user in users: for user in users:
if user == temp: if user == temp:
if not potential or allow_multiple:
potential.append(user) potential.append(user)
else:
if not allow_multiple and len(potential) > 1:
raise ValueError("More than one user matches: " + raise ValueError("More than one user matches: " +
_arg_msg.format(nick, ident, host, realname, account, allow_bot)) _arg_msg.format(nick, ident, host, realname, account, allow_bot))
if not potential and not allow_multiple and not allow_none: if not potential and not allow_multiple and not allow_none:
raise KeyError(_arg_msg.format(nick, ident, host, realname, account, allow_bot)) raise KeyError(_arg_msg.format(nick, ident, host, realname, account, allow_bot))