Fix python 3.12 compatibility
Resolves: #bz2220920 Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>
This commit is contained in:
parent
fcd3852ed9
commit
e871fbf365
@ -11,6 +11,8 @@ License: LGPLv2+
|
|||||||
URL: http://excess.org/urwid/
|
URL: http://excess.org/urwid/
|
||||||
Source0: %{pypi_source urwid}
|
Source0: %{pypi_source urwid}
|
||||||
|
|
||||||
|
Patch1: rhbz-2220920.patch
|
||||||
|
|
||||||
%global _description\
|
%global _description\
|
||||||
Urwid is a Python library for making text console applications. It has\
|
Urwid is a Python library for making text console applications. It has\
|
||||||
many features including fluid interface resizing, support for UTF-8 and\
|
many features including fluid interface resizing, support for UTF-8 and\
|
||||||
@ -25,6 +27,8 @@ control.
|
|||||||
Summary: %summary
|
Summary: %summary
|
||||||
%{?python_provide:%python_provide python3-urwid}
|
%{?python_provide:%python_provide python3-urwid}
|
||||||
BuildRequires: gcc
|
BuildRequires: gcc
|
||||||
|
# patch application
|
||||||
|
BuildRequires: git-core
|
||||||
BuildRequires: python3-devel
|
BuildRequires: python3-devel
|
||||||
BuildRequires: python3-setuptools
|
BuildRequires: python3-setuptools
|
||||||
# needed by selftest suite for test.support
|
# needed by selftest suite for test.support
|
||||||
@ -33,7 +37,7 @@ BuildRequires: python3-test
|
|||||||
%description -n python3-%{srcname} %_description
|
%description -n python3-%{srcname} %_description
|
||||||
|
|
||||||
%prep
|
%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 sed -i -e '/^#!\//, 1d' {} \;
|
||||||
find urwid -type f -name "*.py" -exec chmod 644 {} \;
|
find urwid -type f -name "*.py" -exec chmod 644 {} \;
|
||||||
|
|
||||||
|
|||||||
94
rhbz-2220920.patch
Normal file
94
rhbz-2220920.patch
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
From 44f46f9f389816c154d80a7d3ceddb3730e6eb88 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Alexey Stepanov <penguinolog@users.noreply.github.com>
|
||||||
|
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 <alekseis@nvidia.com>
|
||||||
|
Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>
|
||||||
|
---
|
||||||
|
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 <Python.h>
|
||||||
|
|
||||||
|
@@ -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<end_offs; i++)
|
||||||
|
- screencols += Py_GetWidth(ustr[i]);
|
||||||
|
+ screencols += Py_GetWidth((long int) PyUnicode_ReadChar(text, i));
|
||||||
|
|
||||||
|
return screencols;
|
||||||
|
}
|
||||||
|
@@ -742,16 +740,14 @@ static int Py_CalcTextPos(PyObject *text, Py_ssize_t start_offs,
|
||||||
|
unsigned char * str;
|
||||||
|
Py_ssize_t i, dummy[2], str_len;
|
||||||
|
int screencols, width;
|
||||||
|
- Py_UNICODE *ustr;
|
||||||
|
|
||||||
|
if (PyUnicode_Check(text)) //text_py is unicode string
|
||||||
|
{
|
||||||
|
- ustr = PyUnicode_AS_UNICODE(text);
|
||||||
|
screencols = 0;
|
||||||
|
|
||||||
|
for(i=start_offs; i<end_offs; i++)
|
||||||
|
{
|
||||||
|
- width = Py_GetWidth(ustr[i]);
|
||||||
|
+ width = Py_GetWidth((long int) PyUnicode_ReadChar(text, i));
|
||||||
|
|
||||||
|
if (width+screencols > pref_col)
|
||||||
|
{
|
||||||
|
--
|
||||||
|
2.41.0
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user