File mingw-python3_setenv.patch of Package mingw-python3

diff -rupN --no-dereference Python-3.11.8/Python/pylifecycle.c Python-3.11.8-new/Python/pylifecycle.c
--- Python-3.11.8/Python/pylifecycle.c	2024-02-06 22:21:21.000000000 +0100
+++ Python-3.11.8-new/Python/pylifecycle.c	2024-02-16 22:21:27.427344965 +0100
@@ -61,6 +61,27 @@ extern void _PyIO_Fini(void);
 
 #define PUTS(fd, str) _Py_write_noraise(fd, str, (int)strlen(str))
 
+#if defined(__MINGW32__) && defined(PY_COERCE_C_LOCALE)
+#include <windows.h>
+
+static int
+setenv (const char *var, const char *val, int ovr)
+{
+  BOOL b;
+  char c[2];
+  if (!ovr)
+  {
+    DWORD d;
+    d = GetEnvironmentVariableA (var, c, 2);
+    if (0 != d && GetLastError () != ERROR_ENVVAR_NOT_FOUND)
+      return 1;
+  }
+  b = SetEnvironmentVariableA (var, val);
+  if (b)
+    return 0;
+  return 1;
+}
+#endif
 
 #ifdef __cplusplus
 extern "C" {
openSUSE Build Service is sponsored by