Bug 2148210 - hplip: pcardext Python extension broken
Summary: hplip: pcardext Python extension broken
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: hplip
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Zdenek Dohnal
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-11-24 16:00 UTC by Florian Weimer
Modified: 2022-12-10 01:47 UTC (History)
4 users (show)

Fixed In Version: hplip-3.22.10-3.fc37 hplip-3.22.10-3.fc36 hplip-3.22.10-3.fc35
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-12-10 01:23:53 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Florian Weimer 2022-11-24 16:00:53 UTC
hplip-3.22.6-5.fc38.x86_64 ships an pcardext extension which cannot be loaded:

>>> import pcardext
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: /usr/lib64/python3.11/site-packages/pcardext.so: undefined symbol: PyString_AsStringAndSize
>>> 

Apparently, it hasn't been properly ported to Python.

Comment 1 Florian Weimer 2022-11-24 18:07:54 UTC
I had to disable building the extension in hplip-3.22.10-2.fc38.

Comment 2 Zdenek Dohnal 2022-11-25 10:49:54 UTC
Hi Florian,

thank you for reporting the issue and the patches!

I don't use 'hp-unload' script, which uses the extension, but since this exception probably started to show up since we fully moved to Python3 as OS, IMHO there is no one else using it as well...

So I would let your patch as it is, plus removed the dependent/relevant files. In case there is a demand to make it work I can use the similar implementation as:


static inline int PyString_AsStringAndSize(PyObject* obj, char** buf,
                                           Py_ssize_t* psize) {
    if (PyUnicode_Check(obj)) {
        *buf = PyUnicode_AsUTF8AndSize(obj, psize);
        return *buf == NULL ? -1 : 0;
    } else if (PyBytes_Check(obj)) {
        return PyBytes_AsStringAndSize(obj, buf, psize);
    }
    PyErr_SetString(PyExc_TypeError, "Expecting str or bytes");
    return -1;
}

Comment 3 Zdenek Dohnal 2022-11-25 11:13:47 UTC
I've added some additional comments and reworked two patches:

1) _DBG() in orblite looks like typo for DBG() from common/utils.h
2) switched hpaio's compilation to -D_GNU_SOURCE mode to have declaration for strcasestr() - I saw you mentioned compatibility issues regarding the switch, would you mind telling what problems can show up due the switch? I did a similar change several years ago for hpipp compilation as well.

The proposed update is now here https://src.fedoraproject.org/fork/zdohnal/rpms/hplip/c/e4cf0219ba15894f2f361cc8d3b4a56b32d2b467?branch=c99_cleanup .

Comment 4 Florian Weimer 2022-11-25 12:38:10 UTC
(In reply to Zdenek Dohnal from comment #3)
> I've added some additional comments and reworked two patches:
> 
> 1) _DBG() in orblite looks like typo for DBG() from common/utils.h
> 2) switched hpaio's compilation to -D_GNU_SOURCE mode to have declaration
> for strcasestr() - I saw you mentioned compatibility issues regarding the
> switch, would you mind telling what problems can show up due the switch? I
> did a similar change several years ago for hpipp compilation as well.
> 
> The proposed update is now here
> https://src.fedoraproject.org/fork/zdohnal/rpms/hplip/c/
> e4cf0219ba15894f2f361cc8d3b4a56b32d2b467?branch=c99_cleanup .

Using -D_GNU_SOURCE is fine if you can test things, I could not. Some functions change prototypes/behavior with -D_GNU_SOURCE, e.g. basename and strerror_r.

I think bb_unload is still unused, so I'm not sure why it needs to be patched?

Comment 5 Zdenek Dohnal 2022-12-01 09:42:33 UTC
(In reply to Florian Weimer from comment #4)
> Using -D_GNU_SOURCE is fine if you can test things, I could not. Some
> functions change prototypes/behavior with -D_GNU_SOURCE, e.g. basename and
> strerror_r.

I've tested the basic scanning functionality and it went well, so it looks good to me for now.

> 
> I think bb_unload is still unused, so I'm not sure why it needs to be
> patched?

I would like to keep the patches as small as possible, because as you can see there is a lot of them and upstream mostly does not communicate, just do releases which sometimes include some patches. So I would like to keep the function there (upstream might realize they can unload the binary, as they do with other plugins - it is not a critical though, since the backend is run as one-shot process and then OS cleans it up), so the future rebases might be easier.

Comment 6 Fedora Update System 2022-12-01 11:07:58 UTC
FEDORA-2022-2a678c28c9 has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2022-2a678c28c9

Comment 7 Fedora Update System 2022-12-01 11:32:53 UTC
FEDORA-2022-6e7376d7da has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2022-6e7376d7da

Comment 8 Fedora Update System 2022-12-01 12:00:13 UTC
FEDORA-2022-f90dc81076 has been submitted as an update to Fedora 35. https://bodhi.fedoraproject.org/updates/FEDORA-2022-f90dc81076

Comment 9 Fedora Update System 2022-12-02 02:26:13 UTC
FEDORA-2022-6e7376d7da has been pushed to the Fedora 36 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2022-6e7376d7da`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-6e7376d7da

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 10 Fedora Update System 2022-12-02 02:28:49 UTC
FEDORA-2022-2a678c28c9 has been pushed to the Fedora 37 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2022-2a678c28c9`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-2a678c28c9

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 11 Fedora Update System 2022-12-02 03:19:51 UTC
FEDORA-2022-f90dc81076 has been pushed to the Fedora 35 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2022-f90dc81076`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-f90dc81076

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 12 Fedora Update System 2022-12-10 01:23:53 UTC
FEDORA-2022-2a678c28c9 has been pushed to the Fedora 37 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 13 Fedora Update System 2022-12-10 01:28:13 UTC
FEDORA-2022-6e7376d7da has been pushed to the Fedora 36 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 14 Fedora Update System 2022-12-10 01:47:00 UTC
FEDORA-2022-f90dc81076 has been pushed to the Fedora 35 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.