From 4e4c7574accc7ee09a0ee7e5184c495315d5d554 Mon Sep 17 00:00:00 2001 From: Packit Service Date: Feb 02 2021 06:18:12 +0000 Subject: Apply patch 0001-Return-NULL-string-as-None-from-utf8FromString.patch patch_name: 0001-Return-NULL-string-as-None-from-utf8FromString.patch present_in_specfile: true location_in_specfile: 33 --- diff --git a/python/rpmsystem-py.h b/python/rpmsystem-py.h index c55be37..ae9418b 100644 --- a/python/rpmsystem-py.h +++ b/python/rpmsystem-py.h @@ -52,11 +52,17 @@ typedef Py_ssize_t (*lenfunc)(PyObject *); #define PyInt_AsSsize_t PyLong_AsSsize_t #endif +static inline PyObject * utf8FromString(const char *s) +{ /* In Python 3, we return all strings as surrogate-escaped utf-8 */ #if PY_MAJOR_VERSION >= 3 -#define utf8FromString(_s) PyUnicode_DecodeUTF8(_s, strlen(_s), "surrogateescape") + if (s != NULL) + return PyUnicode_DecodeUTF8(s, strlen(s), "surrogateescape"); #else -#define utf8FromString(_s) PyBytes_FromString(_s) + if (s != NULL) + return PyBytes_FromString(s); #endif + Py_RETURN_NONE; +} #endif /* H_SYSTEM_PYTHON */