UnicodeEncodeError in Python application

Tobias Genannt tobias.genannt at kappa-velorum.net
Fri Dec 16 12:28:24 UTC 2022


Hello,

I'm seeing a crash in a Python application with Unit 1.29 which is not 
happening in Unit 1.28. I'm not sure if I have to change the 
configuration for this version bump because I didn't find an entry in 
the changelog which would point to the problem.
This is the stack trace:

2022/12/16 10:03:34 [alert] 29#29 Python failed to import module 
"netbox.wsgi"
Traceback (most recent call last):
   File "/opt/netbox/netbox/netbox/wsgi.py", line 7, in <module>
     application = get_wsgi_application()
   File 
"/opt/netbox/venv/lib/python3.10/site-packages/django/core/wsgi.py", 
line 12, in get_wsgi_application
     django.setup(set_prefix=False)
   File 
"/opt/netbox/venv/lib/python3.10/site-packages/django/__init__.py", line 
19, in setup
     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
   File 
"/opt/netbox/venv/lib/python3.10/site-packages/django/conf/__init__.py", 
line 92, in __getattr__
     self._setup(name)
   File 
"/opt/netbox/venv/lib/python3.10/site-packages/django/conf/__init__.py", 
line 79, in _setup
     self._wrapped = Settings(settings_module)
   File 
"/opt/netbox/venv/lib/python3.10/site-packages/django/conf/__init__.py", 
line 190, in __init__
     mod = importlib.import_module(self.SETTINGS_MODULE)
   File "/usr/lib/python3.10/importlib/__init__.py", line 126, in 
import_module
     return _bootstrap._gcd_import(name[level:], package, level)
   File "/opt/netbox/netbox/netbox/settings.py", line 50, in <module>
     configuration = importlib.import_module(config_path)
   File "/usr/lib/python3.10/importlib/__init__.py", line 126, in 
import_module
     return _bootstrap._gcd_import(name[level:], package, level)
   File "/opt/netbox/netbox/netbox/configuration.py", line 71, in <module>
     _loaded_configurations = read_configurations(
   File "/opt/netbox/netbox/netbox/configuration.py", line 33, in 
read_configurations
     _import(f"{config_module}.{main_config}", main_config_path, 
loaded_configurations)
   File "/opt/netbox/netbox/netbox/configuration.py", line 25, in _import
     print(f"\U0001f9ec loaded config '{path}'")
UnicodeEncodeError: 'ascii' codec can't encode character '\U0001f9ec' in 
position 0: ordinal not in range(128)

You can find the contents of the problematic file (last strack trace 
entry) here:
https://github.com/tobiasge/netbox-docker/blob/new-unit/docker/configuration.docker.py

I'm using this configuration for Unit:
https://github.com/tobiasge/netbox-docker/blob/new-unit/docker/nginx-unit.json

In the image I have the LANG variable set to 'C.utf8'.

The output of 'locale -a' is this:
C
C.utf8
POSIX

Thanks in advance for any hints on how to fix this.

Greetings,
Tobias


More information about the unit mailing list