-
Notifications
You must be signed in to change notification settings - Fork 4
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
Import fails when /usr/libexec/platform-python is python 2.7 #17
Comments
3 tasks
I wrote a proposed fix here: #18 |
ian-hurst
changed the title
Import fails on CentOS 7
Import fails when /usr/libexec/platform-python is python 2.7
Oct 30, 2024
@nforro just wondering, can we get a new release that includes this fix? Thanks! |
Oh, right, sorry, I was going to do that but it slipped my mind. |
All good, thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What happened? What is the problem?
Just as the title says, when I try to
import rpm
on a system whereplatform-python
is 2.7 (RHEL/CentOS 7.x), rpm-shim unexpectedly raises asubprocess.CalledProcessError
:This is a new issue introduced by my own commit here c06a940
So sorry about this. RHEL 7 is end of life, of course, so this wasn't even a scenario to test. But I actually have production CentOS 7 systems still (via paid support from tuxcare), so it's relevant to me.
What did you expect to happen?
The expected behavior is the
import rpm
does not raise a CalledProcessError when it tries/usr/libexec/platform-python
interpreter. It needn't succeed to import the rpm module, but it should proceed to the next interpreter when it fails, rather than raising.The root cause is python 2.7's
importlib
doesn't implementmachinery
.A workaround might be to catch the ImportError and return a dict with empty keys, like this:
Other approaches exit too, but this was my first thought.
Example URL(s)
No response
Steps to reproduce
1. On CentOS 7 or equivalent, create a virtualenv with any python 3+ 2. Activate the virtualenv and run `python -c 'import rpm'` 3. See the exception raised
Workaround
Participation
The text was updated successfully, but these errors were encountered: