Files
MINGW-packages/mingw-w64-python3/1830-mingw-implement-setenv-for-PY_COERCE_C_LOCALE.patch

31 lines
833 B
Diff

diff -Naur Python-3.7.0-orig/Python/pylifecycle.c Python-3.7.0/Python/pylifecycle.c
--- Python-3.7.0-orig/Python/pylifecycle.c 2018-07-12 10:22:50.526110200 +0300
+++ Python-3.7.0/Python/pylifecycle.c 2018-07-12 10:22:56.017319900 +0300
@@ -40,6 +40,26 @@
#define PyWindowsConsoleIO_Check(op) (PyObject_TypeCheck((op), &PyWindowsConsoleIO_Type))
#endif
+#if defined(__MINGW32__) && defined(PY_COERCE_C_LOCALE)
+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
+
_Py_IDENTIFIER(flush);
_Py_IDENTIFIER(name);
_Py_IDENTIFIER(stdin);