Added test whether wchar_t is signed or not. A signed wchar_t is not usable as internal unicode type base for Py_UNICODE since the unicode implementation assumes an unsigned type.
diff --git a/configure.in b/configure.in
index b2deb65..d3760af 100644
--- a/configure.in
+++ b/configure.in
@@ -2689,6 +2689,25 @@
 ])
 AC_MSG_RESULT($have_ucs4_tcl)
 
+# check whether wchar_t is signed or not
+if test "$wchar_h" = yes
+then
+  # check whether wchar_t is signed or not
+  AC_MSG_CHECKING(whether wchar_t is signed)
+  AC_CACHE_VAL(ac_cv_wchar_t_signed, [
+  AC_TRY_RUN([
+  #include <wchar.h>
+  int main()
+  {
+        exit((((wchar_t) -1) < ((wchar_t) 0)) ? 1 : 0);
+  }
+  ],
+  ac_cv_wchar_t_signed=yes,
+  ac_cv_wchar_t_signed=no,
+  ac_cv_wchar_t_signed=yes)])
+  AC_MSG_RESULT($ac_cv_wchar_t_signed)
+fi
+  
 AC_MSG_CHECKING(what type to use for unicode)
 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
 AC_ARG_ENABLE(unicode, 
@@ -2730,12 +2749,15 @@
   UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
   AC_DEFINE(Py_USING_UNICODE, 1,
   [Define if you want to have a Unicode type.])
-  if test "$unicode_size" = "$ac_cv_sizeof_wchar_t"
+
+  # wchar_t is only usable if it maps to an unsigned type
+  if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
+          -a "$ac_cv_wchar_t_signed" == "no"
   then
     PY_UNICODE_TYPE="wchar_t"
     AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
     [Define if you have a useable wchar_t type defined in wchar.h; useable
-     means wchar_t must be 16-bit unsigned type. (see
+     means wchar_t must be an unsigned type with at least 16 bits. (see
      Include/unicodeobject.h).])
     AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
   elif test "$ac_cv_sizeof_short" = "$unicode_size"