UnicodeEncodeError attempting to send sales report

Hi all, I get the following error when attempting to email a sales report using either the Desktop client or sao, so I assume the error is related to the server environment, possibly a missing Python module.

Can anyone point me in the right direction?


Traceback (most recent call last):
  File "/trytond/wsgi.py", line 109, in dispatch_request
    return endpoint(request, **request.view_args)
  File "/trytond/protocols/dispatcher.py", line 43, in rpc
    return methods.get(request.rpc_method, _dispatch)(
  File "/trytond/wsgi.py", line 75, in wrapper
    return func(request, *args, **kwargs)
  File "/trytond/protocols/wrappers.py", line 189, in wrapper
    return func(request, pool, *args, **kwargs)
  File "/trytond/protocols/dispatcher.py", line 204, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/trytond/ir/email_.py", line 515, in get_default
  File "/trytond/ir/email_.py", line 537, in get_addresses
    return [
  File "/trytond/ir/email_.py", line 538, in <listcomp>
    _formataddr((name, email))
  File "/trytond/ir/email_.py", line 59, in _formataddr
UnicodeEncodeError: 'ascii' codec can't encode character '\ufeff' in position 0: ordinal not in range(128)

Fault: 'ascii' codec can't encode character '\ufeff' in position 0: ordinal not in range(128)

trytond is running using Python 3.9 on FreeBSD 13.2.

Python3.9 modules in base OS:

dale@whizzer:~ % pkg info | grep py39
py39-pip-22.3.1                Tool for installing and managing Python packages
py39-setuptools-63.1.0         Python packages installer
py39-speedtest-cli-2.1.3       Command line interface for testing internet bandwidth
py39-sqlite3-3.9.16_7          Standard Python binding to the SQLite3 library (Python 3.9)
dale@whizzer:~ % 

Python modules installed in venv:

(venv) [tryton@whizzer ~/trytond]$ pip list
Package                       Version
----------------------------- --------
certifi                       2023.5.7
charset-normalizer            3.1.0
defusedxml                    0.7.1
forex-python                  1.8
Genshi                        0.7.7
idna                          3.4
lxml                          4.9.2
MarkupSafe                    2.1.3
passlib                       1.7.4
pip                           23.1.2
polib                         1.2.0
proteus                       6.8.0
psycopg2                      2.9.6
pycountry                     22.3.5
python-dateutil               2.8.2
python-magic                  0.4.27
python-sql                    1.4.0
python-stdnum                 1.18
relatorio                     0.10.1
requests                      2.31.0
setuptools                    58.1.0
simpleeval                    0.9.13
simplejson                    3.19.1
six                           1.16.0
sqlite3                       0.0.0
trytond                       6.8.1
trytond-account               6.8.1
trytond-account-asset         6.8.0
trytond-account-fr            6.8.0
trytond-account-invoice       6.8.1
trytond-account-invoice-stock 6.8.0
trytond-account-product       6.8.0
trytond-company               6.8.0
trytond-country               6.8.0
trytond-currency              6.8.0
trytond-party                 6.8.0
trytond-party-siret           6.8.0
trytond-product               6.8.0
trytond-purchase              6.8.1
trytond-sale                  6.8.1
trytond-stock                 6.8.1
urllib3                       2.0.3
Werkzeug                      2.3.6
(venv) [tryton@whizzer ~/trytond]$

See Support RFC6530 on email formatting (#10650) · Issues · Tryton / Tryton · GitLab

1 Like

Thank you @ced, it appears I had inadvertendly used a non-ascii character in the party contact email address. I re-typed the email address and now email is sent correctly.

I had speculated the issue was likely caused by copy/paste performed from Tad (a CSV file viewer viewing my master customer CSV), and pasted into a Party contact. The pasted string has quote characters around the email address and CR at the ending, and I assume I left a quote or CR in the string when it was saved. Testing though shows the contact cannot be saved if either quote character or the CR is in the contact value (value fails validation), so the root cause remains unknown.

However, it can’t be denied that the issue did not re-occur after re-typing the email address using the web client.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.