[Python-Dev] Adventures with x64, VS7 and VS8 on Windows

Mark Hammond mhammond at skippinet.com.au
Tue May 22 04:58:45 CEST 2007


Hi Marc-Andre,

> +1 from me.
>
> If think this is simply a bug introduced with the UCS4 patches in
> Python 2.2.
>
> unicodeobject.h already has this code:
>
> #ifndef PY_UNICODE_TYPE
>
> /* Windows has a usable wchar_t type (unless we're using UCS-4) */
> # if defined(MS_WIN32) && Py_UNICODE_SIZE == 2
> #  define HAVE_USABLE_WCHAR_T
> #  define PY_UNICODE_TYPE wchar_t
> # endif
>
> # if defined(Py_UNICODE_WIDE)
> #  define PY_UNICODE_TYPE Py_UCS4
> # endif
>
> #endif
>
> But for some reason, pyconfig.h defines:
>
> /* Define as the integral type used for Unicode representation. */
> #define PY_UNICODE_TYPE unsigned short
>
> /* Define as the size of the unicode type. */
> #define Py_UNICODE_SIZE SIZEOF_SHORT
>
> /* Define if you have a useable wchar_t type defined in
> wchar.h; useable
>    means wchar_t must be 16-bit unsigned type. (see
>    Include/unicodeobject.h). */
> #if Py_UNICODE_SIZE == 2
> #define HAVE_USABLE_WCHAR_T
> #endif
>
> disabling the default settings in the unicodeobject.h.

Yes, that does appear strange.  The following patch works for me, keeps
Python building and appears to solve my problem.  Any objections?

Mark


Index: pyconfig.h
===================================================================
--- pyconfig.h  (revision 55487)
+++ pyconfig.h  (working copy)
@@ -491,22 +491,13 @@
 /* Define if you want to have a Unicode type. */
 #define Py_USING_UNICODE

-/* Define as the integral type used for Unicode representation. */
-#define PY_UNICODE_TYPE unsigned short
-
 /* Define as the size of the unicode type. */
-#define Py_UNICODE_SIZE SIZEOF_SHORT
+/* This is enough for unicodeobject.h to do the "right thing" on Windows.
*/
+#define Py_UNICODE_SIZE 2

-/* Define if you have a useable wchar_t type defined in wchar.h; useable
-   means wchar_t must be 16-bit unsigned type. (see
-   Include/unicodeobject.h). */
-#if Py_UNICODE_SIZE == 2
-#define HAVE_USABLE_WCHAR_T
-
 /* Define to indicate that the Python Unicode representation can be passed
    as-is to Win32 Wide API.  */
 #define Py_WIN_WIDE_FILENAMES
-#endif

 /* Use Python's own small-block memory-allocator. */
 #define WITH_PYMALLOC 1



More information about the Python-Dev mailing list