Files
MINGW-packages/mingw-w64-python3/0200-MINGW-build-in-windows-modules-winreg.patch
2014-10-11 14:46:25 +01:00

83 lines
2.4 KiB
Diff

diff -urN a/configure.ac b/configure.ac
--- a/configure.ac 2014-10-11 14:19:07.957757200 +0100
+++ b/configure.ac 2014-10-11 14:19:10.613909200 +0100
@@ -2540,6 +2540,14 @@
fi])
AC_MSG_RESULT($with_dbmliborder)
+
+# Determine if windows modules should be used.
+AC_SUBST(USE_WIN32_MODULE)
+USE_WIN32_MODULE='#'
+case $host in
+ *-*-mingw*) USE_WIN32_MODULE=;;
+esac
+
# Determine if signalmodule should be used.
AC_SUBST(USE_SIGNAL_MODULE)
AC_SUBST(SIGNAL_OBJS)
diff -urN a/Modules/Setup.config.in b/Modules/Setup.config.in
--- a/Modules/Setup.config.in 2014-10-11 14:19:08.700799700 +0100
+++ b/Modules/Setup.config.in 2014-10-11 14:19:10.615909300 +0100
@@ -12,5 +12,8 @@
# The signal module
@USE_SIGNAL_MODULE@signal signalmodule.c
+# build-in modules for windows platform:
+@USE_WIN32_MODULE@winreg ../PC/winreg.c
+
# The rest of the modules previously listed in this file are built
# by the setup.py script in Python 2.1 and later.
diff -urN a/PC/winreg.c b/PC/winreg.c
--- a/PC/winreg.c 2014-10-11 14:19:08.760803200 +0100
+++ b/PC/winreg.c 2014-10-11 14:19:10.616909300 +0100
@@ -16,6 +16,25 @@
#include "structmember.h"
#include "windows.h"
+#ifndef SIZEOF_HKEY
+/* used only here */
+#if defined(MS_WIN64)
+# define SIZEOF_HKEY 8
+#elif defined(MS_WIN32)
+# define SIZEOF_HKEY 4
+#else
+# error "SIZEOF_HKEY is not defined"
+#endif
+#endif
+
+#ifndef REG_LEGAL_CHANGE_FILTER
+#define REG_LEGAL_CHANGE_FILTER (\
+ REG_NOTIFY_CHANGE_NAME |\
+ REG_NOTIFY_CHANGE_ATTRIBUTES |\
+ REG_NOTIFY_CHANGE_LAST_SET |\
+ REG_NOTIFY_CHANGE_SECURITY )
+#endif
+
static BOOL PyHKEY_AsHKEY(PyObject *ob, HKEY *pRes, BOOL bNoneOK);
static PyObject *PyHKEY_FromHKEY(HKEY h);
static BOOL PyHKEY_Close(PyObject *obHandle);
@@ -1083,6 +1102,10 @@
static PyObject *
PyDeleteKeyEx(PyObject *self, PyObject *args, PyObject *kwargs)
{
+#ifdef KEY_WOW64_64KEY
+/* KEY_WOW64_64KEY is defined for _WIN32_WINNT >= 0x0502,
+ * i.e. Windows Server 2003 with SP1, Windows XP with SP2
+ * and not supported on w2k. */
HKEY hKey;
PyObject *key;
HMODULE hMod;
@@ -1119,6 +1142,11 @@
return PyErr_SetFromWindowsErrWithFunction(rc, "RegDeleteKeyEx");
Py_INCREF(Py_None);
return Py_None;
+#else /*def KEY_WOW64_64KEY*/
+ PyErr_SetString(PyExc_NotImplementedError,
+ "not implemented on this platform");
+ return NULL;
+#endif
}
static PyObject *