Unable to print exception as string on python3
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