File python-3.9.10-mingw-fixes.patch of Package mingw64-python3
diff -ur a/Python-3.9.10/Include/pyport.h b/Python-3.9.10/Include/pyport.h
--- a/Python-3.9.10/Include/pyport.h 2022-01-13 22:21:23.000000000 +0100
+++ b/Python-3.9.10/Include/pyport.h 2022-10-17 15:29:22.889418923 +0200
@@ -70,12 +70,14 @@
#define PY_ULLONG_MAX ULLONG_MAX
#endif
+#ifndef PY_UINT32_T
#define PY_UINT32_T uint32_t
#define PY_UINT64_T uint64_t
/* Signed variants of the above */
#define PY_INT32_T int32_t
#define PY_INT64_T int64_t
+#endif
/* If PYLONG_BITS_IN_DIGIT is not defined then we'll use 30-bit digits if all
the necessary integer types are available, and we're on a 64-bit platform
diff -ur a/Python-3.9.10/Modules/_cursesmodule.c b/Python-3.9.10/Modules/_cursesmodule.c
--- a/Python-3.9.10/Modules/_cursesmodule.c 2022-01-13 22:21:23.000000000 +0100
+++ b/Python-3.9.10/Modules/_cursesmodule.c 2022-10-17 15:29:22.897418440 +0200
@@ -104,6 +104,9 @@
#include "Python.h"
+#ifdef _WIN32
+#include <windows.h>
+#endif
#ifdef __hpux
#define STRICT_SYSV_CURSES
diff -ur a/Python-3.9.10/Modules/_curses_panel.c b/Python-3.9.10/Modules/_curses_panel.c
--- a/Python-3.9.10/Modules/_curses_panel.c 2022-01-13 22:21:23.000000000 +0100
+++ b/Python-3.9.10/Modules/_curses_panel.c 2022-10-17 15:29:22.893418681 +0200
@@ -14,7 +14,11 @@
#include "py_curses.h"
-#include <panel.h>
+#ifdef HAVE_NCURSESW
+#include <ncursesw/panel.h>
+#else
+#include <ncurses/panel.h>
+#endif
typedef struct {
PyObject *PyCursesError;
diff -ur a/Python-3.9.10/Modules/faulthandler.c b/Python-3.9.10/Modules/faulthandler.c
--- a/Python-3.9.10/Modules/faulthandler.c 2022-01-13 22:21:23.000000000 +0100
+++ b/Python-3.9.10/Modules/faulthandler.c 2022-10-17 15:36:43.418691715 +0200
@@ -1003,7 +1003,7 @@
}
#endif
-#ifdef _MSC_VER
+#ifdef _WIN32
/* Visual Studio: configure abort() to not display an error message nor
open a popup asking to report the fault. */
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
diff -ur a/Python-3.9.10/Modules/_localemodule.c b/Python-3.9.10/Modules/_localemodule.c
--- a/Python-3.9.10/Modules/_localemodule.c 2022-01-13 22:21:23.000000000 +0100
+++ b/Python-3.9.10/Modules/_localemodule.c 2022-10-17 15:29:22.893418681 +0200
@@ -144,7 +144,7 @@
static int
locale_decode_monetary(PyObject *dict, struct lconv *lc)
{
-#ifndef MS_WINDOWS
+#if !defined(MS_WINDOWS) || defined(__MINGW32__)
int change_locale;
change_locale = (!locale_is_ascii(lc->int_curr_symbol)
|| !locale_is_ascii(lc->currency_symbol)
@@ -253,7 +253,7 @@
Py_DECREF(obj); \
} while (0)
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) && !defined(__MINGW32__)
/* Use _W_* fields of Windows struct lconv */
#define GET_LOCALE_STRING(ATTR) PyUnicode_FromWideChar(lc->_W_ ## ATTR, -1)
#else
diff -ur a/Python-3.9.10/Modules/_pickle.c b/Python-3.9.10/Modules/_pickle.c
--- a/Python-3.9.10/Modules/_pickle.c 2022-01-13 22:21:23.000000000 +0100
+++ b/Python-3.9.10/Modules/_pickle.c 2022-10-17 15:29:22.897418440 +0200
@@ -8,7 +8,13 @@
# error "Py_BUILD_CORE_BUILTIN or Py_BUILD_CORE_MODULE must be defined"
#endif
+#define FLOAT _FLOAT
+#define LONG _LONG
+#define INT _INT
#include "Python.h"
+#undef FLOAT
+#undef LONG
+#undef INT
#include "structmember.h" // PyMemberDef
PyDoc_STRVAR(pickle_module_doc,
diff -ur a/Python-3.9.10/Modules/posixmodule.c b/Python-3.9.10/Modules/posixmodule.c
--- a/Python-3.9.10/Modules/posixmodule.c 2022-01-13 22:21:23.000000000 +0100
+++ b/Python-3.9.10/Modules/posixmodule.c 2022-10-17 15:29:22.893418681 +0200
@@ -297,7 +297,7 @@
# define HAVE_SYSTEM 1
# include <process.h>
#else
-# ifdef _MSC_VER
+# ifdef MS_WINDOWS
/* Microsoft compiler */
# define HAVE_GETPPID 1
# define HAVE_GETLOGIN 1
@@ -330,7 +330,7 @@
# define HAVE_SYSTEM 1
# define HAVE_WAIT 1
# define HAVE_TTYNAME 1
-# endif /* _MSC_VER */
+# endif /* MS_WINDOWS */
#endif /* ! __WATCOMC__ || __QNX__ */
_Py_IDENTIFIER(__fspath__);
@@ -341,7 +341,7 @@
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=94a0f0f978acae17]*/
-#ifndef _MSC_VER
+#ifndef MS_WINDOWS
#if defined(__sgi)&&_COMPILER_VERSION>=700
/* declare ctermid_r if compiling with MIPSPro 7.x in ANSI C mode
@@ -349,7 +349,7 @@
extern char *ctermid_r(char *);
#endif
-#endif /* !_MSC_VER */
+#endif /* !MS_WINDOWS */
#if defined(__VXWORKS__)
# include <vxCpuLib.h>
@@ -410,7 +410,7 @@
# endif
#endif
-#ifdef _MSC_VER
+#ifdef MS_WINDOWS
# ifdef HAVE_DIRECT_H
# include <direct.h>
# endif
@@ -432,7 +432,7 @@
# include <shellapi.h> // ShellExecute()
# include <lmcons.h> // UNLEN
# define HAVE_SYMLINK
-#endif /* _MSC_VER */
+#endif /* MS_WINDOWS */
#ifndef MAXPATHLEN
# if defined(PATH_MAX) && PATH_MAX > 1024
diff -ur a/Python-3.9.10/Modules/readline.c b/Python-3.9.10/Modules/readline.c
--- a/Python-3.9.10/Modules/readline.c 2022-01-13 22:21:23.000000000 +0100
+++ b/Python-3.9.10/Modules/readline.c 2022-10-17 15:29:22.897418440 +0200
@@ -44,6 +44,9 @@
#endif
#endif
#endif
+#ifdef _WIN32
+#include <winsock.h>
+#endif
/*
* It is possible to link the readline module to the readline
diff -ur a/Python-3.9.10/Modules/selectmodule.c b/Python-3.9.10/Modules/selectmodule.c
--- a/Python-3.9.10/Modules/selectmodule.c 2022-01-13 22:21:23.000000000 +0100
+++ b/Python-3.9.10/Modules/selectmodule.c 2022-10-17 15:37:42.311156098 +0200
@@ -155,9 +155,9 @@
v = PyObject_AsFileDescriptor( o );
if (v == -1) goto finally;
-#if defined(_MSC_VER)
+#if defined(_WIN32)
max = 0; /* not used for Win32 */
-#else /* !_MSC_VER */
+#else /* !_WIN32 */
if (!_PyIsSelectable_fd(v)) {
PyErr_SetString(PyExc_ValueError,
"filedescriptor out of range in select()");
@@ -165,7 +165,7 @@
}
if (v > max)
max = v;
-#endif /* _MSC_VER */
+#endif /* _WIN32 */
FD_SET(v, set);
/* add object and its file descriptor to the list */
diff -ur a/Python-3.9.10/Modules/socketmodule.c b/Python-3.9.10/Modules/socketmodule.c
--- a/Python-3.9.10/Modules/socketmodule.c 2022-01-13 22:21:23.000000000 +0100
+++ b/Python-3.9.10/Modules/socketmodule.c 2022-10-17 15:29:22.893418681 +0200
@@ -302,7 +302,7 @@
# endif
/* Macros based on the IPPROTO enum, see: https://bugs.python.org/issue29515 */
-#ifdef MS_WINDOWS
+#ifdef _MSC_VER
#define IPPROTO_ICMP IPPROTO_ICMP
#define IPPROTO_IGMP IPPROTO_IGMP
#define IPPROTO_GGP IPPROTO_GGP
@@ -333,6 +333,8 @@
#define IPPROTO_PGM IPPROTO_PGM // WinSock2 only
#define IPPROTO_L2TP IPPROTO_L2TP // WinSock2 only
#define IPPROTO_SCTP IPPROTO_SCTP // WinSock2 only
+#else
+#include <winsock2.h>
#endif /* MS_WINDOWS */
/* Provides the IsWindows7SP1OrGreater() function */
diff -ur a/Python-3.9.10/Modules/_ssl.c b/Python-3.9.10/Modules/_ssl.c
--- a/Python-3.9.10/Modules/_ssl.c 2022-01-13 22:21:23.000000000 +0100
+++ b/Python-3.9.10/Modules/_ssl.c 2022-10-17 15:33:15.699311916 +0200
@@ -5573,7 +5573,7 @@
return result;
}
-#ifdef _MSC_VER
+#ifdef _WIN32
static PyObject*
certEncodingType(DWORD encodingType)
diff -ur a/Python-3.9.10/Modules/timemodule.c b/Python-3.9.10/Modules/timemodule.c
--- a/Python-3.9.10/Modules/timemodule.c 2022-01-13 22:21:23.000000000 +0100
+++ b/Python-3.9.10/Modules/timemodule.c 2022-10-17 15:39:05.158178257 +0200
@@ -754,7 +754,7 @@
return NULL;
}
-#if defined(_MSC_VER) || (defined(__sun) && defined(__SVR4)) || defined(_AIX) || defined(__VXWORKS__)
+#if defined(_WIN32) || (defined(__sun) && defined(__SVR4)) || defined(_AIX) || defined(__VXWORKS__)
if (buf.tm_year + 1900 < 1 || 9999 < buf.tm_year + 1900) {
PyErr_SetString(PyExc_ValueError,
"strftime() requires year in [1; 9999]");
diff -ur a/Python-3.9.10/PC/_testconsole.c b/Python-3.9.10/PC/_testconsole.c
--- a/Python-3.9.10/PC/_testconsole.c 2022-01-13 22:21:23.000000000 +0100
+++ b/Python-3.9.10/PC/_testconsole.c 2022-10-17 15:29:22.897418440 +0200
@@ -6,7 +6,7 @@
#ifdef MS_WINDOWS
-#include "..\modules\_io\_iomodule.h"
+#include "../Modules/_io/_iomodule.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -101,7 +101,7 @@
Py_RETURN_NONE;
}
-#include "clinic\_testconsole.c.h"
+#include "clinic/_testconsole.c.h"
PyMethodDef testconsole_methods[] = {
_TESTCONSOLE_WRITE_INPUT_METHODDEF
diff -ur a/Python-3.9.10/Programs/python.c b/Python-3.9.10/Programs/python.c
--- a/Python-3.9.10/Programs/python.c 2022-01-13 22:21:23.000000000 +0100
+++ b/Python-3.9.10/Programs/python.c 2022-10-17 15:29:22.897418440 +0200
@@ -2,7 +2,7 @@
#include "Python.h"
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) && !defined(__MINGW32__)
int
wmain(int argc, wchar_t **argv)
{
diff -ur a/Python-3.9.10/Python/fileutils.c b/Python-3.9.10/Python/fileutils.c
--- a/Python-3.9.10/Python/fileutils.c 2022-01-13 22:21:23.000000000 +0100
+++ b/Python-3.9.10/Python/fileutils.c 2022-10-17 15:29:22.897418440 +0200
@@ -2204,7 +2204,7 @@
assert(decimal_point != NULL);
assert(thousands_sep != NULL);
-#ifndef MS_WINDOWS
+#if !defined(MS_WINDOWS) || defined(__MINGW32__)
int change_locale = 0;
if ((strlen(lc->decimal_point) > 1 || ((unsigned char)lc->decimal_point[0]) > 127)) {
change_locale = 1;
--- a/Python-3.9.10/Python/pylifecycle.c 2023-02-07 13:50:41.365342170 +0100
+++ b/Python-3.9.10/Python/pylifecycle.c 2023-02-07 13:51:31.169166722 +0100
@@ -2493,7 +2493,7 @@
#else
PyOS_sighandler_t handler;
/* Special signal handling for the secure CRT in Visual Studio 2005 */
-#if defined(_MSC_VER) && _MSC_VER >= 1400
+#if (defined(_MSC_VER) && _MSC_VER >= 1400) || defined(__MINGW32__)
switch (sig) {
/* Only these signals are valid */
case SIGINT: