diff options
author | Alexis Hildebrandt <afh@surryhill.net> | 2024-02-25 17:53:27 +0100 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2024-07-08 10:12:07 -0700 |
commit | a3600645ec13c060e9c6270b78eae894b54a2999 (patch) | |
tree | ead673422db0ed85140d865d4a35cb35c6e82f1f /src | |
parent | ecaf66e51120b335f005d5d6de3b6284a376fadd (diff) | |
download | fork-ledger-a3600645ec13c060e9c6270b78eae894b54a2999.tar.gz fork-ledger-a3600645ec13c060e9c6270b78eae894b54a2999.tar.bz2 fork-ledger-a3600645ec13c060e9c6270b78eae894b54a2999.zip |
Fix conditional compilation of Python <3.12 code
Diffstat (limited to 'src')
-rw-r--r-- | src/py_utils.cc | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/py_utils.cc b/src/py_utils.cc index 5dae1ab9..43d71f4b 100644 --- a/src/py_utils.cc +++ b/src/py_utils.cc @@ -103,7 +103,6 @@ struct string_from_python return; #endif - const Py_UNICODE* value; Py_ssize_t size; string str; @@ -134,9 +133,9 @@ struct string_from_python default: assert("PyUnicode_KIND returned an unexpected kind" == NULL); } -#else +#else // PY_MINOR_VERSION >= 3 size = PyUnicode_GET_SIZE(obj_ptr); - value = PyUnicode_AS_UNICODE(obj_ptr); + const Py_UNICODE* value = PyUnicode_AS_UNICODE(obj_ptr); #if Py_UNICODE_SIZE == 2 // UTF-16 utf8::unchecked::utf16to8(value, value + size, std::back_inserter(str)); #elif Py_UNICODE_SIZE == 4 // UTF-32 @@ -144,7 +143,7 @@ struct string_from_python #else assert("Py_UNICODE has an unexpected size" == NULL); #endif -#endif +#endif // PY_MINOR_VERSION >= 3 void* storage = reinterpret_cast<converter::rvalue_from_python_storage<string> *> |