diff --git a/python-urwid.spec b/python-urwid.spec index 90a1964..29e1325 100644 --- a/python-urwid.spec +++ b/python-urwid.spec @@ -11,6 +11,8 @@ License: LGPLv2+ URL: http://excess.org/urwid/ Source0: %{pypi_source urwid} +Patch1: rhbz-2220920.patch + %global _description\ Urwid is a Python library for making text console applications. It has\ many features including fluid interface resizing, support for UTF-8 and\ @@ -25,6 +27,8 @@ control. Summary: %summary %{?python_provide:%python_provide python3-urwid} BuildRequires: gcc +# patch application +BuildRequires: git-core BuildRequires: python3-devel BuildRequires: python3-setuptools # needed by selftest suite for test.support @@ -33,7 +37,7 @@ BuildRequires: python3-test %description -n python3-%{srcname} %_description %prep -%setup -q -n %{srcname}-%{version} +%autosetup -Sgit -n %{srcname}-%{version} find urwid -type f -name "*.py" -exec sed -i -e '/^#!\//, 1d' {} \; find urwid -type f -name "*.py" -exec chmod 644 {} \; diff --git a/rhbz-2220920.patch b/rhbz-2220920.patch new file mode 100644 index 0000000..4d625b5 --- /dev/null +++ b/rhbz-2220920.patch @@ -0,0 +1,94 @@ +From 44f46f9f389816c154d80a7d3ceddb3730e6eb88 Mon Sep 17 00:00:00 2001 +From: Alexey Stepanov +Date: Mon, 4 Sep 2023 16:53:13 +0200 +Subject: [PATCH] Fix #583: python 3.12 compatibility (#598) + +* Fix #583: python 3.12 compatibility + +Replace as pep-0393 recommended: + +* `PyUnicode_AS_UNICODE` by `PyUnicode_ReadChar` + (use Stable API) + +* Enable PR tests on python 3.12 + +* Force Limited API following pep-0384 + +--------- + +Backported to Fedora rawhide +Upstream commit: +https://github.com/urwid/urwid/commit/44f46f9f389816c154d80a7d3ceddb3730e6eb88 + +Co-authored-by: Aleksei Stepanov +Signed-off-by: Tomas Tomecek +--- + source/str_util.c | 14 +++++--------- + 1 file changed, 5 insertions(+), 9 deletions(-) + +diff --git a/source/str_util.c b/source/str_util.c +index 5ed1356..a8480d7 100644 +--- a/source/str_util.c ++++ b/source/str_util.c +@@ -21,6 +21,8 @@ + */ + + #define PY_SSIZE_T_CLEAN ++// Use Limited API for Python 3.7.0 release and newer ++#define Py_LIMITED_API 0x030700f0 + + #include + +@@ -476,13 +478,11 @@ offs -- offset"; + static int Py_IsWideChar(PyObject *text, Py_ssize_t offs) + { + const unsigned char *str; +- Py_UNICODE *ustr; + Py_ssize_t ret[2], str_len; + + if (PyUnicode_Check(text)) //text_py is unicode string + { +- ustr = PyUnicode_AS_UNICODE(text); +- return (Py_GetWidth((long int)ustr[offs]) == 2); ++ return (Py_GetWidth((long int) PyUnicode_ReadChar(text, offs)) == 2); + } + + #ifndef PYTHON3 +@@ -656,15 +656,13 @@ static Py_ssize_t Py_CalcWidth(PyObject *text, Py_ssize_t start_offs, + unsigned char * str; + Py_ssize_t i, ret[2], str_len; + int screencols; +- Py_UNICODE *ustr; + + if (PyUnicode_Check(text)) //text_py is unicode string + { +- ustr = PyUnicode_AS_UNICODE(text); + screencols = 0; + + for(i=start_offs; i pref_col) + { +-- +2.41.0 +