summaryrefslogtreecommitdiffstats
path: root/Modules/_localemodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_localemodule.c')
-rw-r--r--Modules/_localemodule.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c
index 8441f1e..fb2837e 100644
--- a/Modules/_localemodule.c
+++ b/Modules/_localemodule.c
@@ -49,7 +49,11 @@ static PyObject *Error;
static PyObject*
str2uni(const char* s)
{
+#ifdef HAVE_BROKEN_MBSTOWCS
+ size_t needed = strlen(s);
+#else
size_t needed = mbstowcs(NULL, s, 0);
+#endif
size_t res1;
wchar_t smallbuf[30];
wchar_t *dest;
@@ -67,7 +71,11 @@ str2uni(const char* s)
}
/* This shouldn't fail now */
res1 = mbstowcs(dest, s, needed+1);
+#ifdef HAVE_BROKEN_MBSTOWCS
+ assert(res1 != (size_t)-1);
+#else
assert(res1 == needed);
+#endif
res2 = PyUnicode_FromWideChar(dest, res1);
if (dest != smallbuf)
PyMem_Free(dest);