[pypy-commit] cffi default: Don't accidentally decode ints as unicodes.
arigo
noreply at buildbot.pypy.org
Fri Aug 3 16:47:47 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r762:257df59c4f2a
Date: 2012-08-03 16:39 +0200
http://bitbucket.org/cffi/cffi/changeset/257df59c4f2a/
Log: Don't accidentally decode ints as unicodes.
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -3838,8 +3838,9 @@
return PyString_FromStringAndSize(start, length);
}
#ifdef HAVE_WCHAR_H
- else if (cd->c_type->ct_itemdescr->ct_size == sizeof(wchar_t)) {
+ else if (cd->c_type->ct_itemdescr->ct_flags & CT_PRIMITIVE_CHAR) {
const wchar_t *start = (wchar_t *)cd->c_data;
+ assert(cd->c_type->ct_itemdescr->ct_size == sizeof(wchar_t));
if (length < 0 && cd->c_type->ct_flags & CT_ARRAY) {
length = get_array_length(cd);
}
@@ -3868,7 +3869,8 @@
return PyString_FromStringAndSize(cd->c_data, 1);
}
#ifdef HAVE_WCHAR_H
- else if (cd->c_type->ct_size == sizeof(wchar_t)) {
+ else if (cd->c_type->ct_flags & CT_PRIMITIVE_CHAR) {
+ assert(cd->c_type->ct_size == sizeof(wchar_t));
return _my_PyUnicode_FromWideChar((wchar_t *)cd->c_data, 1);
}
#endif
More information about the pypy-commit
mailing list