UnicodeEncodeError in Python application

Andrew Clayton andrew at digital-domain.net
Thu Jan 5 15:42:09 UTC 2023


On Sun, 1 Jan 2023 18:37:29 +0100
Tobias Genannt <tobias.genannt at kappa-velorum.net> wrote:

> Hello,
> 
> this patch didn't work in our Netbox container.

OK. Here's another (replacement) one to try...

<patch>
diff --git a/src/python/nxt_python.c b/src/python/nxt_python.c
index bdb04579..3c03252d 100644
--- a/src/python/nxt_python.c
+++ b/src/python/nxt_python.c
@@ -75,8 +75,13 @@ static nxt_python_proto_t    nxt_py_proto;
 static nxt_int_t
 nxt_python3_init_config(nxt_int_t pep405)
 {
-    PyStatus  status;
-    PyConfig  config;
+    PyStatus     status;
+    PyConfig     config;
+    PyPreConfig  preconfig;
+
+    PyPreConfig_InitIsolatedConfig(&preconfig);
+    preconfig.utf8_mode = 1;
+    Py_PreInitialize(&preconfig);
 
     PyConfig_InitIsolatedConfig(&config);
 
</patch>

Cheers,
Andrew


More information about the unit mailing list