Skip to content
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

Fix: No traceback when Python interpreter is running with -P, allow -P in shebang lines #2089

Conversation

jrohel
Copy link
Contributor

@jrohel jrohel commented Apr 26, 2024

Closes #2078

jrohel added 2 commits April 26, 2024 12:03
There was code in dnf and dnf-automatic to support running them from
the git tree. This was a developer-oriented hack that should not exist
in production code. It assumed that when running an installed dnf,
the `sys.path[0]` contains `/usr/bin`. If not, it overwrites
the contents of `sys.path[0]`.

This is a problem when running the Python interpreter with the `-P`
parameter (meaning: Don't automatically prepend a potentially unsafe
path to sys.path such as the current directory, the script's directory
or an empty string.)

The fix removes this developer-oriented hack. Developers should instead
set PYTHONPATH in the environment.
There was a bug in dnf and dnf-automatic that caused traceback
when running the Python interpreter with the `-P` argument.
Since the bug has been fixed, the `-P` argument can be used.
@ppisar ppisar self-assigned this Apr 29, 2024
Copy link
Contributor

@ppisar ppisar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good. Though tests in testing farm were not executed because of "package dnf-data-4.20.0-1.20240426113905572340.pr2089.3.gc9da8e61.fc41.noarch from @commandline requires /etc/dnf/dnf.conf, but none of the providers can be installed". The failure is probably unrelated.

@ppisar ppisar merged commit 22fc33c into rpm-software-management:master Apr 29, 2024
7 of 11 checks passed
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

Successfully merging this pull request may close these issues.

dnf traceback when running Python with -P
2 participants