head 1.1; access; symbols; locks; strict; comment @// @; 1.1 date 2026.06.29.06.48.04; author wiz; state Exp; branches; next ; commitid quX8MQXg50co2FLG; desc @@ 1.1 log @ledger32: fix build with Python 3.12+ Enable python option by default again. Bump PKGREVISION. @ text @$NetBSD$ Fix build with Python 3.12+. --- src/py_utils.cc.orig 2026-06-29 06:33:49.654740789 +0000 +++ src/py_utils.cc @@@@ -114,19 +114,11 @@@@ struct string_from_python #endif VERIFY(PyUnicode_Check(obj_ptr)); - Py_ssize_t size = PyUnicode_GET_SIZE(obj_ptr); - const Py_UNICODE* value = PyUnicode_AS_UNICODE(obj_ptr); + Py_ssize_t size = 0; + const char* utf8_value = PyUnicode_AsUTF8AndSize(obj_ptr, &size); - string str; -#if Py_UNICODE_SIZE == 2 // UTF-16 - utf8::unchecked::utf16to8(value, value + size, std::back_inserter(str)); -#elif Py_UNICODE_SIZE == 4 // UTF-32 - utf8::unchecked::utf32to8(value, value + size, std::back_inserter(str)); -#else - assert("Py_UNICODE has an unexpected size" == NULL); -#endif - - if (value == 0) throw_error_already_set(); + if (utf8_value == 0) throw_error_already_set(); + string str(utf8_value, size); void* storage = reinterpret_cast *> (data)->storage.bytes; @