[Python-checkins] r85579 - python/branches/py3k/Python/fileutils.c
victor.stinner
python-checkins at python.org
Sun Oct 17 00:47:37 CEST 2010
Author: victor.stinner
Date: Sun Oct 17 00:47:37 2010
New Revision: 85579
Log:
_Py_wreadlink() uses _Py_char2wchar() to decode the result, to support
surrogate characters.
Modified:
python/branches/py3k/Python/fileutils.c
Modified: python/branches/py3k/Python/fileutils.c
==============================================================================
--- python/branches/py3k/Python/fileutils.c (original)
+++ python/branches/py3k/Python/fileutils.c Sun Oct 17 00:47:37 2010
@@ -307,6 +307,7 @@
{
char *cpath;
char cbuf[PATH_MAX];
+ wchar_t *wbuf;
int res;
size_t r1;
@@ -324,11 +325,15 @@
return -1;
}
cbuf[res] = '0円'; /* buf will be null terminated */
- r1 = mbstowcs(buf, cbuf, bufsiz);
- if (r1 == -1) {
+ wbuf = _Py_char2wchar(cbuf);
+ r1 = wcslen(wbuf);
+ if (bufsiz <= r1) {
+ PyMem_Free(wbuf);
errno = EINVAL;
return -1;
}
+ wcsncpy(buf, wbuf, bufsiz);
+ PyMem_Free(wbuf);
return (int)r1;
}
#endif
More information about the Python-checkins
mailing list