TypeError: must use keyword argument for key function using python3
Encountered issue with python3, there yet seems to be a couple of cases using .sort() with 'cmp' instead of 'key'... namely:
Traceback (most recent call last):
File "/trytond/wsgi.py", line 47, in dispatch_request
return endpoint(request, **request.view_args)
File "/trytond/protocols/dispatcher.py", line 41, in rpc
request, database_name, *request.rpc_params)
File "/trytond/wsgi.py", line 39, in auth_required
return wrapped(*args, **kwargs)
File "/trytond/protocols/wrappers.py", line 105, in wrapper
return func(request, pool, *args, **kwargs)
File "/trytond/protocols/dispatcher.py", line 165, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
File "/trytond/modules/account/fiscalyear.py", line 172, in write
values['periods'].sort(lambda x, y:
TypeError: must use keyword argument for key function
this is the code snippet:
@classmethod
def write(cls, *args):
actions = iter(args)
args = []
for fiscalyears, values in zip(actions, actions):
if values.get('post_move_sequence'):
for fiscalyear in fiscalyears:
if (fiscalyear.post_move_sequence
and fiscalyear.post_move_sequence.id !=
values['post_move_sequence']):
cls.raise_user_error('change_post_move_sequence', (
fiscalyear.rec_name,))
values = values.copy()
if 'periods' in values:
operator = ['delete', 'remove', 'create', 'write', 'add']
values['periods'].sort(lambda x, y:
cmp(operator.index(x[0]), operator.index(y[0])))
args.extend((fiscalyears, values))
super(FiscalYear, cls).write(*args)
(I believe another case is stock_supply/purchase_request.py)