Skip to content

python bindings for libdnf5 are like walking on a tightrope with no safety net #2198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
noahfriedman opened this issue Apr 16, 2025 · 2 comments

Comments

@noahfriedman
Copy link

noahfriedman commented Apr 16, 2025

I'm writing my own dnf5 search command, and I've discovered that if you do anything not implemented by the libdnf5 library, such as using QueryCmp_REGEX, the code throws a C++ exception that is not translated into a python exception, and the python interpreter simply crashes, usually with a segfault and core dump.

I've attached a small test case, but this is only one example of dozens I've run across just trying to inspect SWIG objects that, clearly, I'm not supposed to look at. Even aside from that, there are filters that support some flags and not others, e.g. filter_arch throws an exception if you use QueryCmp_CONTAINS, but other filters accept it. The hapless python programmer has absolutely no way of knowing which filters tolerate which flags without digging through the source code.

I can work around these problems, but is there any chance these exceptions could be made to translate into the respective language bindings in a more fault-tolerant way?

example.py.txt

@kontura
Copy link
Contributor

kontura commented Apr 22, 2025

Can share what libdnf5 version are you using?

I have not investigated but perhaps this was recently improved by #2118?

@noahfriedman
Copy link
Author

libdnf5 5.2.12.0-2.fc41 x86_64 fedora-41
python3-libdnf5 5.2.12.0-2.fc41 x86_64 fedora-41
python3 3.13.2-1.fc41 x86_64 fedora-41

I'll give that change a try, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants