Changed a run-time test into compile-time
This commit is contained in:
parent
ff666a4469
commit
63c8d9054c
1 changed files with 4 additions and 5 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue