Bug 2220920

Summary: python-urwid broken with Python 3.12: PyUnicode_AS_UNICODE has been removed
Product: [Fedora] Fedora Reporter: Ankur Sinha (FranciscoD) <sanjay.ankur>
Component: python-urwidAssignee: Tomas Tomecek <ttomecek>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 39CC: mhroncok, ttomecek
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: python-urwid-2.1.2-10.fc40 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-09-05 10:25:27 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2135404, 2217400, 2220621, 2226500    

Description Ankur Sinha (FranciscoD) 2023-07-06 14:12:08 UTC
In Python 3.12, PyUnicdeo_AS_UNICODE has been removed:

https://peps.python.org/pep-0623/#python-3-12

It's still used in https://github.com/urwid/urwid/blob/f7d2f2f6a8a519bd64ebbe1895e5c6b5948199f3/source/str_util.c



Attempting to build urwid will give errors of this form:

gcc ... -fPIC -I/usr/include/python3.12 -c source/str_util.c -o
build/temp.linux-x86_64-cpython-312/source/str_util.o
source/str_util.c: In function ‘Py_IsWideChar’:
source/str_util.c:484:16: warning: implicit declaration of function
‘PyUnicode_AS_UNICODE’; did you mean ‘PyUnicode_AsUCS4’?
[-Wimplicit-function-declaration]
  484 |         ustr = PyUnicode_AS_UNICODE(text);
      |                ^~~~~~~~~~~~~~~~~~~~
      |                PyUnicode_AsUCS4
source/str_util.c:484:14: warning: assignment to ‘Py_UNICODE *’ {aka
‘int *’} from ‘int’ makes pointer from integer without a cast
[-Wint-conversion]
  484 |         ustr = PyUnicode_AS_UNICODE(text);
      |              ^
source/str_util.c: In function ‘Py_CalcWidth’:
source/str_util.c:663:14: warning: assignment to ‘Py_UNICODE *’ {aka
‘int *’} from ‘int’ makes pointer from integer without a cast
[-Wint-conversion]
  663 |         ustr = PyUnicode_AS_UNICODE(text);
      |              ^
source/str_util.c: In function ‘Py_CalcTextPos’:
source/str_util.c:749:14: warning: assignment to ‘Py_UNICODE *’ {aka
‘int *’} from ‘int’ makes pointer from integer without a cast
[-Wint-conversion]
  749 |         ustr = PyUnicode_AS_UNICODE(text);
      |              ^


Reproducible: Always




Affects: python-urwid-2.1.2-9.fc39

Comment 1 Fedora Release Engineering 2023-08-16 08:11:59 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 39 development cycle.
Changing version to 39.

Comment 2 Ankur Sinha (FranciscoD) 2023-09-04 15:32:23 UTC
A fix is now available (and looks simple enough to carry the patch):

https://github.com/urwid/urwid/pull/598/files