Tryton - Issues

 

Issue6665

Title TypeError: must use keyword argument for key function using python3
Priority bug Status resolved
Superseder Nosy List ced, pokoli, reviewbot, risto3, roundup-bot
Type crash Components account
Assigned To ced Keywords Python3, easy, review
Reviews 35631002
View: 35631002

Created on 2017-07-24.07:34:55 by risto3, last changed by risto3.

Messages
msg36247 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2017-10-11.23:22:50
So if you have another issue, create a new issue.
msg36246 (view) Author: [hidden] (risto3) Date: 2017-10-11.23:18:16
as I mentioned in the first message, I believe stock_supply/purchase_request.py
has a similar case...
New changeset 0d134ac7ef45 by Cédric Krier in branch '4.4':
Remove ordering of periods operations
http://hg.tryton.org/modules/account/rev/0d134ac7ef45

New changeset b3d20d787c24 by Cédric Krier in branch '4.4':
Do not clear args in FiscalYear.write
http://hg.tryton.org/modules/account/rev/b3d20d787c24

New changeset b17920fc9b2d by Cédric Krier in branch '4.2':
Remove ordering of periods operations
http://hg.tryton.org/modules/account/rev/b17920fc9b2d

New changeset 03f34ba9259d by Cédric Krier in branch '4.2':
Do not clear args in FiscalYear.write
http://hg.tryton.org/modules/account/rev/03f34ba9259d

New changeset b9cd4c397dd0 by Cédric Krier in branch '4.0':
Remove ordering of periods operations
http://hg.tryton.org/modules/account/rev/b9cd4c397dd0

New changeset 6ef01d98e0de by Cédric Krier in branch '4.0':
Do not clear args in FiscalYear.write
http://hg.tryton.org/modules/account/rev/6ef01d98e0de

New changeset 90211f788eb7 by Cédric Krier in branch '3.8':
Remove ordering of periods operations
http://hg.tryton.org/modules/account/rev/90211f788eb7

New changeset 480beb8afade by Cédric Krier in branch '3.8':
Do not clear args in FiscalYear.write
http://hg.tryton.org/modules/account/rev/480beb8afade

New changeset 0f45ae8a09f9 by Cédric Krier in branch '3.6':
Remove ordering of periods operations
http://hg.tryton.org/modules/account/rev/0f45ae8a09f9

New changeset 2fdab97eeb3b by Cédric Krier in branch '3.6':
Do not clear args in FiscalYear.write
http://hg.tryton.org/modules/account/rev/2fdab97eeb3b
New changeset fd676ddd59b1 by Cédric Krier in branch 'default':
Do not clear args in FiscalYear.write
http://hg.tryton.org/modules/account/rev/fd676ddd59b1
New changeset 73fc013931d8 by Cédric Krier in branch 'default':
Remove ordering of periods operations
http://hg.tryton.org/modules/account/rev/73fc013931d8
msg35891 (view) Author: [hidden] (pokoli) (Tryton committer) (Tryton translator) Date: 2017-09-28.11:55:44
Indeed since changeset b2fe4361f5db this error is raised on the CI. See: 

https://drone.tryton.org/tryton/modules.account/18/20
review35631002 updated at https://codereview.tryton.org/35631002/#ps1
msg35866 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2017-09-28.00:33:41
Here is review35631002 that removes this code as it has no effect since r cae474455419
msg34901 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2017-07-30.14:09:02
Off-topic: we are waiting your contribution at issue2178
msg34900 (view) Author: [hidden] (risto3) Date: 2017-07-30.13:38:41
please provide then a means to login to rietveld/codereview without g$$gle services. 

(see https://degooglisons-internet.org and rms' https://stallman.org/google.html)

Has the tryton project considered any alternatives preventing this vendor lock-in such as kallithea or perhaps reviewboard?
msg34899 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2017-07-30.10:58:25
So please do not send patches if you do not follow the procedure.
msg34898 (view) Author: [hidden] (risto3) Date: 2017-07-30.08:50:12
apparently rietveld still requires a g$$gle account. Sorry, don't do that.
Any reason why the user/pw from here (roundup) cannot be used?
msg34888 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2017-07-29.23:34:13
Please to submit patch follow: http://www.tryton.org/how-to-contribute.html
msg34737 (view) Author: [hidden] (risto3) Date: 2017-07-24.13:22:08
May not be strictly what is intended, but using:

@@ -169,8 +169,7 @@
             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])))
+                values['periods'].sort(key=lambda x: operator.index(x[0]))
             args.extend((fiscalyears, values))
         super(FiscalYear, cls).write(*args)

let's me proceed, for now.
msg34728 (view) Author: [hidden] (risto3) Date: 2017-07-24.07:34:55
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)
History
Date User Action Args
2017-10-12 18:20:32risto3settitle: TypeError: must use keyword argument for key function in account/fiscalyear.py using python3 -> TypeError: must use keyword argument for key function using python3
2017-10-11 23:22:51cedsetstatus: chatting -> resolved
messages: + msg36247
2017-10-11 23:18:16risto3setstatus: resolved -> chatting
messages: + msg36246
2017-10-11 22:32:37roundup-botsetmessages: + msg36233
2017-09-28 13:12:06roundup-botsetmessages: + msg35899
2017-09-28 12:48:46roundup-botsetstatus: testing -> resolved
nosy: + roundup-bot
messages: + msg35897
2017-09-28 11:55:44pokolisetnosy: + pokoli
messages: + msg35891
2017-09-28 00:44:22reviewbotsetnosy: + reviewbot
messages: + msg35868
2017-09-28 00:33:42cedsetstatus: in-progress -> testing
reviews: 35631002
messages: + msg35866
keyword: + review
2017-09-28 00:30:40cedsetstatus: chatting -> in-progress
assignedto: ced

Showing 10 items. Show all history (warning: this could be VERY long)