diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/py_utils.cc | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/py_utils.cc b/src/py_utils.cc index c513def4..710dca4b 100644 --- a/src/py_utils.cc +++ b/src/py_utils.cc @@ -111,13 +111,12 @@ struct string_from_python const Py_UNICODE* value = PyUnicode_AS_UNICODE(obj_ptr); string str; - if (sizeof(Py_UNICODE) == 2) // UTF-16 +#if Py_UNICODE_SIZE == 2 // UTF-16 utf8::unchecked::utf16to8(value, value + size, std::back_inserter(str)); - else if (sizeof(Py_UNICODE) == 4) // UTF-32 +#elif Py_UNICODE_SIZE == 4 // UTF-32 utf8::unchecked::utf32to8(value, value + size, std::back_inserter(str)); -#if !defined(NO_ASSERTS) - else - assert(! "Py_UNICODE has an unexpected size"); +#else + assert("Py_UNICODE has an unexpected size" == NULL); #endif if (value == 0) throw_error_already_set(); |