Tryton - Issues

 

Issue7097

Title Unable to print exception as string on python3
Priority bug Status resolved
Superseder Nosy List ced, meigallodixital, pokoli, reviewbot, roundup-bot
Type crash Components trytond
Assigned To pokoli Keywords Python3, review
Reviews 43941002
View: 43941002

Created on 2018-01-30.11:58:59 by pokoli, last changed by roundup-bot.

Messages
New changeset 1b9b71da52cb by Sergi Almacellas Abellana in branch '4.6':
Only convert to unicode exceptions string on python2
http://hg.tryton.org/trytond/rev/1b9b71da52cb

New changeset f0bb73c74c38 by Sergi Almacellas Abellana in branch '4.4':
Only convert to unicode exceptions string on python2
http://hg.tryton.org/trytond/rev/f0bb73c74c38
New changeset f304b28960de by Sergi Almacellas Abellana in branch 'default':
Only convert to unicode exceptions string on python2
http://hg.tryton.org/trytond/rev/f304b28960de
review43941002 updated at https://codereview.tryton.org/43941002/#ps20001
msg38117 (view) Author: [hidden] (pokoli) (Tryton committer) (Tryton translator) Date: 2018-01-30.13:40:46
Here is review43941002 which defines the method only for python2.
msg38116 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2018-01-30.12:35:29
I guess this method should be protected to be defined only under Python2
msg38114 (view) Author: [hidden] (pokoli) (Tryton committer) (Tryton translator) Date: 2018-01-30.11:58:59
The following code on python3 raises a RecursionError:

from trytond.exceptions import UserError
e = UserError('test')
print(e)

  File "/usr/local/lib/python3.5/dist-packages/trytond/exceptions.py", line 8, in __str__
    return str(self).encode('utf-8')
RecursionError: maximum recursion depth exceeded


The problem is the __str__ definition of TrytonException [1], which 2to3 converts to: 

class TrytonException(Exception):

    def __str__(self):
        return str(self).encode('utf-8')

And raises the RecursionError because it calls itself. 



[1] http://hg.tryton.org/trytond/file/b2729144b556/trytond/exceptions.py#l8
History
Date User Action Args
2018-02-25 00:57:43roundup-botsetmessages: + msg38597
2018-02-07 12:16:15roundup-botsetstatus: testing -> resolved
nosy: + roundup-bot
messages: + msg38269
2018-01-30 13:55:39reviewbotsetnosy: + reviewbot
messages: + msg38118
2018-01-30 13:40:47pokolisetstatus: chatting -> testing
reviews: 43941002
messages: + msg38117
keyword: + review
assignedto: pokoli
2018-01-30 12:35:30cedsetstatus: unread -> chatting
nosy: + ced
messages: + msg38116
2018-01-30 12:00:43meigallodixitalsetnosy: + meigallodixital
2018-01-30 11:58:59pokolicreate

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