MINGW-packages/mingw-w64-python3.13/0163-sys-module-Implement-flags-is_mingw-and-use_alt_sep.patch
Christoph Reiter 04c9ed3700 python3.13: Add 3.13.7
* add libb2 as dep
* remove "-Wl,--large-address-aware", default now via makepkg
* remove 2to3 logic, no longer in Python
2025-09-08 22:02:30 +02:00

68 lines
2.2 KiB
Diff

From 1926e748a451c9f75dcebac4d5ddb158a004cef4 Mon Sep 17 00:00:00 2001
From: Alexey Pavlov <alexpux@gmail.com>
Date: Fri, 5 Sep 2025 15:15:15 +0300
Subject: [PATCH 163/N] sys module: Implement flags "is_mingw" and
"use_alt_sep"
---
Python/sysmodule.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 48b46da..83a6d98 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -177,6 +177,28 @@ PySys_GetObject(const char *name)
return value;
}
+static int
+use_alt_sep()
+{
+#ifdef MS_WINDOWS
+ char* msystem = getenv("MSYSTEM");
+ if (msystem != NULL && strcmp(msystem, "") != 0) {
+ return 1;
+ }
+#endif
+ return 0;
+}
+
+static int
+is_mingw_platform()
+{
+#ifdef __MINGW32__
+ return 1;
+#else
+ return 0;
+#endif
+}
+
static int
sys_set_object(PyInterpreterState *interp, PyObject *key, PyObject *v)
{
@@ -3141,11 +3163,13 @@ hash_info -- a named tuple with information about the hash algorithm.\n\
hexversion -- version information encoded as a single integer\n\
implementation -- Python implementation information.\n\
int_info -- a named tuple with information about the int implementation.\n\
+is_mingw -- integer value if Python builded with mingw-w64 toolchain\n\
maxsize -- the largest supported length of containers.\n\
maxunicode -- the value of the largest Unicode code point\n\
platform -- platform identifier\n\
prefix -- prefix used to find the Python library\n\
thread_info -- a named tuple with information about the thread implementation.\n\
+use_alt_sep -- indicate if need use posix style path setparator for path normalize\n\
version -- the version of this interpreter as a string\n\
version_info -- version information as a named tuple\n\
"
@@ -3623,6 +3647,9 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict)
SET_SYS_FROM_STRING("byteorder", "little");
#endif
+ SET_SYS("is_mingw", PyLong_FromLong(is_mingw_platform()));
+ SET_SYS("use_alt_sep", PyLong_FromLong(use_alt_sep()));
+
#if defined(MS_WINDOWS) && defined(Py_ENABLE_SHARED)
SET_SYS("dllhandle", PyLong_FromVoidPtr(PyWin_DLLhModule));
SET_SYS_FROM_STRING("winver", PyWin_DLLVersionString);