diff options
| author | Richard Mathot <rim@odoo.com> | 2019-07-09 12:26:46 +0000 |
|---|---|---|
| committer | Richard Mathot <rim@odoo.com> | 2019-07-09 12:26:46 +0000 |
| commit | 0ec0a4a32e98f2288e419dcb0627cfd972f32034 (patch) | |
| tree | df82a5ab73d16e71c021538758fc0eca662456e1 /addons/web/static/src | |
| parent | 7be62eb852023a7829ccd25107daccf2b5db41c5 (diff) | |
[FIX] models: avoid Unicode error when translating that error message
The patch fa492d87f42f97d05ba93255a77e24c35158fe62 has been backported
from Odoo 12.0, that runs on Python 3.
The string '\n\n({} {}, {} {})' to be formatted is a byte-string in
Python 2, while the return value of _() is always a unicode-string.
As format() is (too?) nice, it attempts to convert the unicode-strings
into ascii in order to inject them in the format pattern.
With some languages that are written in ascii, this works -- by chance.
When you use non-ascii languages like Japanese, it fails.
We then fix that issue by using unicode-strings in the formatting
pattern.
#OneCharacterPatch B-)
opw-2032016
-----------------------------
For full technical understanding:
Python 2.7.16 (default, Mar 11 2019, 18:59:25)
[GCC 8.2.1 20181127] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> '{}'.format('test')
'test'
>>> '{}'.format(u'test')
'test'
>>> '{}'.format(u'エ')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\u30a8' in position 0: ordinal not in range(128)
>>> u'{}'.format(u'エ')
u'\u30a8'
closes odoo/odoo#34698
Signed-off-by: Richard Mathot (rim) <rim@openerp.com>
Diffstat (limited to 'addons/web/static/src')
0 files changed, 0 insertions, 0 deletions
