summaryrefslogtreecommitdiffstats
path: root/Modules/_localemodule.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2008-09-03 18:58:51 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2008-09-03 18:58:51 (GMT)
commitfff953048f965b4f0a56f775d3f4ce1634df3da7 (patch)
tree528a28abc4354994c6818caac6257c52bc0d1704 /Modules/_localemodule.c
parent658fad8aae60e6c25a102fb56884bf66577366f8 (diff)
downloadcpython-fff953048f965b4f0a56f775d3f4ce1634df3da7.zip
cpython-fff953048f965b4f0a56f775d3f4ce1634df3da7.tar.gz
cpython-fff953048f965b4f0a56f775d3f4ce1634df3da7.tar.bz2
Issue #3696: Error parsing arguments on OpenBSD <= 4.4 and Cygwin.
Patch by Amaury Forgeot d'Arc, reviewed by me.
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);