hpmudext and scanext python extensions don't work with Python3.10

Bug #1933973 reported by zdohnal
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
HPLIP
New
Undecided
Unassigned
hplip (Fedora)
Fix Released
Undecided

Bug Description

Hi,

we have a report in Fedora rawhide[1], where Python3.10 is already introduced, and hpfax crashes there with SystemError:

Truncated backtrace:
device.py:558:probeDevices:SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

Traceback (most recent call last):
  File "/usr/lib/cups/backend/hpfax", line 151, in <module>
    probed_devices = device.probeDevices(['usb', 'par'], filter={'fax-type': (operator.gt, 0)})
  File "/usr/share/hplip/base/device.py", line 558, in probeDevices
    result_code, data = hpmudext.probe_devices(bn)
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

The change which the message mentions happened in Python3.10[2]. It is based on PEP 353[3], which forbids int as a sequence indice, and introduces Py_ssize_t indices (most times 'typedef'ed ssize_t from glibc).
The patch defines the mentioned macro in specific source files, and adds range checks for numeric variables coming from PyArg_ParseTuple(). It is because the length variable coming from the function is of Py_ssize_t, which is basically long int, and the hpmud functions uses int, so the value must be checked and adjusted in case it is bigger/smaller than INT_MAX/INT_MIN.

Would you mind merging the patch?

Thank you in advance,

Zdenek

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1976465
[2] https://docs.python.org/3.10/whatsnew/3.10.html#id2
[3] https://www.python.org/dev/peps/pep-0353/

Revision history for this message
zdohnal (zdohnal) wrote :
description: updated
Changed in hplip (Fedora):
importance: Unknown → Undecided
status: Unknown → In Progress
Changed in hplip (Fedora):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.