diff options
author | John Wiegley <johnw@newartisans.com> | 2012-02-10 19:56:48 -1000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2012-02-11 16:53:31 -1000 |
commit | 63c8d9054c7d12f0035d82f20fd776a5cc015de8 (patch) | |
tree | 3f1c9d642934bd95a75a74a36607a4310fbe0df4 /src/py_utils.cc | |
parent | ff666a44693c27cb88592ef44974e505ce0624bc (diff) | |
download | fork-ledger-63c8d9054c7d12f0035d82f20fd776a5cc015de8.tar.gz fork-ledger-63c8d9054c7d12f0035d82f20fd776a5cc015de8.tar.bz2 fork-ledger-63c8d9054c7d12f0035d82f20fd776a5cc015de8.zip |
Changed a run-time test into compile-time
Diffstat (limited to 'src/py_utils.cc')
-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(); |