From db7e6996294cc66d3f9d132267fbc64dd7b97acb Mon Sep 17 00:00:00 2001 From: Alexey Pavlov Date: Fri, 5 Sep 2025 15:15:15 +0300 Subject: [PATCH 003/N] sysmodule: Implement flags "_is_mingw", "is_mingw_ucrt" and "_use_alt_sep" --- Python/sysmodule.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 993763f..e722a59 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -177,6 +177,38 @@ PySys_GetObject(const char *name) return value; } +static int +use_alt_sep(void) +{ +#ifdef MS_WINDOWS + char* msystem = getenv("MSYSTEM"); + if (msystem != NULL && strcmp(msystem, "") != 0) { + return 1; + } +#endif + return 0; +} + +static int +is_mingw(void) +{ +#ifdef __MINGW32__ + return 1; +#else + return 0; +#endif +} + +static int +is_mingw_ucrt(void) +{ +#if defined(__MINGW32__) && defined(_UCRT) + return 1; +#else + return 0; +#endif +} + static int sys_set_object(PyInterpreterState *interp, PyObject *key, PyObject *v) { @@ -3622,6 +3654,10 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict) SET_SYS_FROM_STRING("byteorder", "little"); #endif + SET_SYS("_is_mingw", PyLong_FromLong(is_mingw())); + SET_SYS("_is_mingw_ucrt", PyLong_FromLong(is_mingw_ucrt())); + SET_SYS("_use_alt_sep", PyLong_FromLong(use_alt_sep())); + #ifdef MS_COREDLL SET_SYS("dllhandle", PyLong_FromVoidPtr(PyWin_DLLhModule)); SET_SYS_FROM_STRING("winver", PyWin_DLLVersionString);