From c12feaa550d5cfa6109cc8f37fa59606dcd69ae5 Mon Sep 17 00:00:00 2001 From: Minmin Gong Date: Mon, 4 Jul 2016 21:31:12 -0700 Subject: [PATCH 1/2] Fix building with UNICODE character set. --- Modules/_localemodule.c | 16 ++++++++-------- Modules/_pickle.c | 4 ++++ Modules/_winapi.c | 2 +- Modules/mmapmodule.c | 14 +++++++------- Modules/posixmodule.c | 10 +++++----- PC/dl_nt.c | 2 +- Python/sysmodule.c | 4 ++-- 7 files changed, 28 insertions(+), 24 deletions(-) diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c index a92fb10..b11369d 100644 --- a/Modules/_localemodule.c +++ b/Modules/_localemodule.c @@ -289,14 +289,14 @@ PyLocale_getdefaultlocale(PyObject* self) PyOS_snprintf(encoding, sizeof(encoding), "cp%d", GetACP()); - if (GetLocaleInfo(LOCALE_USER_DEFAULT, - LOCALE_SISO639LANGNAME, - locale, sizeof(locale))) { + if (GetLocaleInfoA(LOCALE_USER_DEFAULT, + LOCALE_SISO639LANGNAME, + locale, sizeof(locale))) { Py_ssize_t i = strlen(locale); locale[i++] = '_'; - if (GetLocaleInfo(LOCALE_USER_DEFAULT, - LOCALE_SISO3166CTRYNAME, - locale+i, (int)(sizeof(locale)-i))) + if (GetLocaleInfoA(LOCALE_USER_DEFAULT, + LOCALE_SISO3166CTRYNAME, + locale+i, (int)(sizeof(locale)-i))) return Py_BuildValue("ss", locale, encoding); } @@ -306,8 +306,8 @@ PyLocale_getdefaultlocale(PyObject* self) locale[0] = '0'; locale[1] = 'x'; - if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IDEFAULTLANGUAGE, - locale+2, sizeof(locale)-2)) { + if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IDEFAULTLANGUAGE, + locale+2, sizeof(locale)-2)) { return Py_BuildValue("ss", locale, encoding); } diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 7121ac8..98b1833 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -1,6 +1,10 @@ #include "Python.h" #include "structmember.h" +#ifdef UNICODE +#undef UNICODE +#endif + PyDoc_STRVAR(pickle_module_doc, "Optimized C implementation for the Python pickle module."); diff --git a/Modules/_winapi.c b/Modules/_winapi.c index 2396fe2..6e02c40 100644 --- a/Modules/_winapi.c +++ b/Modules/_winapi.c @@ -72,7 +72,7 @@ check_CancelIoEx() { if (has_CancelIoEx == -1) { - HINSTANCE hKernel32 = GetModuleHandle("KERNEL32"); + HINSTANCE hKernel32 = GetModuleHandleA("KERNEL32"); * (FARPROC *) &Py_CancelIoEx = GetProcAddress(hKernel32, "CancelIoEx"); has_CancelIoEx = (Py_CancelIoEx != NULL); diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index 50cec24..198353c 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -516,7 +516,7 @@ mmap_resize_method(mmap_object *self, /* Change the size of the file */ SetEndOfFile(self->file_handle); /* Create another mapping object and remap the file view */ - self->map_handle = CreateFileMapping( + self->map_handle = CreateFileMappingA( self->file_handle, NULL, PAGE_READWRITE, @@ -1434,12 +1434,12 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict) off_lo = (DWORD)(offset & 0xFFFFFFFF); /* For files, it would be sufficient to pass 0 as size. For anonymous maps, we have to pass the size explicitly. */ - m_obj->map_handle = CreateFileMapping(m_obj->file_handle, - NULL, - flProtect, - size_hi, - size_lo, - m_obj->tagname); + m_obj->map_handle = CreateFileMappingA(m_obj->file_handle, + NULL, + flProtect, + size_hi, + size_lo, + m_obj->tagname); if (m_obj->map_handle != NULL) { m_obj->data = (char *) MapViewOfFile(m_obj->map_handle, dwDesiredAccess, diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 4dc7c49..4f516de 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -3477,7 +3477,7 @@ _listdir_windows_no_opendir(path_t *path, PyObject *list) PyObject *v; HANDLE hFindFile = INVALID_HANDLE_VALUE; BOOL result; - WIN32_FIND_DATA FileData; + WIN32_FIND_DATAA FileData; char namebuf[MAX_PATH+4]; /* Overallocate for "\*.*" */ /* only claim to have space for MAX_PATH */ Py_ssize_t len = Py_ARRAY_LENGTH(namebuf)-4; @@ -3567,7 +3567,7 @@ _listdir_windows_no_opendir(path_t *path, PyObject *list) return NULL; Py_BEGIN_ALLOW_THREADS - hFindFile = FindFirstFile(namebuf, &FileData); + hFindFile = FindFirstFileA(namebuf, &FileData); Py_END_ALLOW_THREADS if (hFindFile == INVALID_HANDLE_VALUE) { int error = GetLastError(); @@ -3596,7 +3596,7 @@ _listdir_windows_no_opendir(path_t *path, PyObject *list) Py_DECREF(v); } Py_BEGIN_ALLOW_THREADS - result = FindNextFile(hFindFile, &FileData); + result = FindNextFileA(hFindFile, &FileData); Py_END_ALLOW_THREADS /* FindNextFile sets error to ERROR_NO_MORE_FILES if it got to the end of the directory. */ @@ -3805,8 +3805,8 @@ os__getfullpathname_impl(PyModuleDef *module, path_t *path) char outbuf[MAX_PATH]; char *temp; - if (!GetFullPathName(path->narrow, Py_ARRAY_LENGTH(outbuf), - outbuf, &temp)) { + if (!GetFullPathNameA(path->narrow, Py_ARRAY_LENGTH(outbuf), + outbuf, &temp)) { win32_error_object("GetFullPathName", path->object); return NULL; } diff --git a/PC/dl_nt.c b/PC/dl_nt.c index c87c51e..1d34e84 100644 --- a/PC/dl_nt.c +++ b/PC/dl_nt.c @@ -96,7 +96,7 @@ BOOL WINAPI DllMain (HANDLE hInst, #ifndef MS_DLL_ID // If we have MS_DLL_ID, we don't need to load the string. // 1000 is a magic number I picked out of the air. Could do with a #define, I spose... - LoadString(hInst, 1000, dllVersionBuffer, sizeof(dllVersionBuffer)); + LoadStringA(hInst, 1000, dllVersionBuffer, sizeof(dllVersionBuffer)); #endif #if HAVE_SXS diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 56175d9..0c3ddd7 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -847,9 +847,9 @@ sys_getwindowsversion(PyObject *self) { PyObject *version; int pos = 0; - OSVERSIONINFOEX ver; + OSVERSIONINFOEXA ver; ver.dwOSVersionInfoSize = sizeof(ver); - if (!GetVersionEx((OSVERSIONINFO*) &ver)) + if (!GetVersionExA((OSVERSIONINFOA*) &ver)) return PyErr_SetFromWindowsErr(0); version = PyStructSequence_New(&WindowsVersionType); -- 1.9.5.msysgit.1