Correct usage of sorted() in mongodb_user (#46792)
* Correct usage of sorted() in mongodb_user sorted() can't be called on a list of dicts without supplying a key parameter. This is explained really well in the Sorting HOWTO https://docs.python.org/3.6/howto/sorting.html#key-functions This commit fixes #46791 * Fix PEP8 issues
This commit is contained in:
parent
21d43e6d94
commit
6e409a91ba
1 changed files with 2 additions and 1 deletions
|
@ -178,6 +178,7 @@ import os
|
|||
import ssl as ssl_lib
|
||||
import traceback
|
||||
from distutils.version import LooseVersion
|
||||
from operator import itemgetter
|
||||
|
||||
try:
|
||||
from pymongo.errors import ConnectionFailure
|
||||
|
@ -319,7 +320,7 @@ def check_if_roles_changed(uinfo, roles, db_name):
|
|||
roles_as_list_of_dict = make_sure_roles_are_a_list_of_dict(roles, db_name)
|
||||
uinfo_roles = uinfo.get('roles', [])
|
||||
|
||||
if sorted(roles_as_list_of_dict) == sorted(uinfo_roles):
|
||||
if sorted(roles_as_list_of_dict, key=itemgetter('db')) == sorted(uinfo_roles, key=itemgetter('db')):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
|
Loading…
Reference in a new issue