From 334ec84cff3f54195449002d226763cb22ab7376 Mon Sep 17 00:00:00 2001 From: "biao716.wang" Date: Thu, 7 Sep 2023 13:00:52 +0900 Subject: [PATCH] fix undefined symbol utf8FromString in _rpmb module when frpm rpm_tizen import _rpmb Change-Id: Ib62988c5351070bcade49fbfddbe01788648531d Signed-off-by: biao716.wang --- python/header-py.c | 13 ------------- python/rpmsystem-py.h | 8 +++++++- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/python/header-py.c b/python/header-py.c index 6b60e96..39b4da0 100644 --- a/python/header-py.c +++ b/python/header-py.c @@ -422,19 +422,6 @@ static PyObject * hdr_iternext(hdrObject *s) return res; } -PyObject * utf8FromString(const char *s) -{ -/* In Python 3, we return all strings as surrogate-escaped utf-8 */ -#if PY_MAJOR_VERSION >= 3 - if (s != NULL) - return PyUnicode_DecodeUTF8(s, strlen(s), "surrogateescape"); -#else - if (s != NULL) - return PyBytes_FromString(s); -#endif - Py_RETURN_NONE; -} - int utf8FromPyObject(PyObject *item, PyObject **str) { PyObject *res = NULL; diff --git a/python/rpmsystem-py.h b/python/rpmsystem-py.h index c7e367e..2fc8421 100644 --- a/python/rpmsystem-py.h +++ b/python/rpmsystem-py.h @@ -42,6 +42,12 @@ typedef Py_ssize_t (*lenfunc)(PyObject *); #define CAPSULE_EXTRACT(obj,name) PyCObject_AsVoidPtr(obj) #endif -PyObject * utf8FromString(const char *s); +static inline PyObject * utf8FromString(const char *s) +{ +/* In Python 3, we return all strings as surrogate-escaped utf-8 */ + if (s != NULL) + return PyUnicode_DecodeUTF8(s, strlen(s), "surrogateescape"); + Py_RETURN_NONE; +} #endif /* H_SYSTEM_PYTHON */ -- 2.7.4