Skip to content

bpo-44860: Update test_sysconfig for posix_user platlib #28235

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

Merged
merged 3 commits into from
Sep 9, 2021
Merged

bpo-44860: Update test_sysconfig for posix_user platlib #28235

merged 3 commits into from
Sep 9, 2021

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Sep 8, 2021

Update test_sysconfig.test_user_similar() for the posix_user scheme:
"platlib" doesn't use sys.platlibdir.

https://bugs.python.org/issue44860

Update test_sysconfig.test_user_similar() for the posix_user scheme:
"platlib" doesn't use sys.platlibdir.
@vstinner
Copy link
Member Author

vstinner commented Sep 8, 2021

@uranusjr: Would you mind to review my change?

cc @hroncok @encukou @frenzymadness

self.assertEqual(user_path, global_path.replace(base, user, 1))
expected = global_path.replace(base, user, 1)
# bpo-44860: platlib of posix_user doesn't use sys.platlibdir
if name == 'platlib' and sys.platlibdir != 'lib':
Copy link
Contributor

Choose a reason for hiding this comment

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

What about this? The replacement can always happen.

Suggested change
if name == 'platlib' and sys.platlibdir != 'lib':
if name == 'platlib':

Copy link
Member Author

Choose a reason for hiding this comment

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

str.replace() is not reliabe, the full path may contain the /lib/ substring multiple times. Like /tmp/lib/runtests/lib/python3.9/. I prefer to only use it if it's really needed :-p

Or maybe we should use a more reliable replacement, like a regex?

@vstinner vstinner added the needs backport to 3.10 only security fixes label Sep 8, 2021
@hroncok

This comment has been minimized.

@hroncok

This comment has been minimized.

Copy link
Contributor

@hroncok hroncok left a comment

Choose a reason for hiding this comment

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

This fixes the failure for Fedora. Not sure if this test is worth keeping, but that's a question that is out of scope here.

@vstinner
Copy link
Member Author

vstinner commented Sep 8, 2021

I'm fine with removing the test: it was added 11 years ago by https://bugs.python.org/issue8759 sysconfig evolved a lot in the meanwhile, and the test became less relevant since sys.platlibdir was added to Python 3.9.
https://docs.python.org/dev/library/sys.html#sys.platlibdir

But I don't know the sysconfig module. In case of doubt, I prefer to minimize changes.

@vstinner vstinner merged commit 49acac0 into python:main Sep 9, 2021
@miss-islington
Copy link
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

@vstinner vstinner deleted the platlibdir branch September 9, 2021 09:02
@miss-islington
Copy link
Contributor

Sorry @vstinner, I had trouble checking out the 3.10 backport branch.
Please backport using cherry_picker on command line.
cherry_picker 49acac00c08838d8080ce00d02c05284b94f8fb2 3.10

@vstinner vstinner added needs backport to 3.10 only security fixes and removed needs backport to 3.10 only security fixes labels Sep 9, 2021
@miss-islington
Copy link
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-28251 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Sep 9, 2021
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 9, 2021
Update test_sysconfig.test_user_similar() for the posix_user scheme:
"platlib" doesn't use sys.platlibdir.
(cherry picked from commit 49acac0)

Co-authored-by: Victor Stinner <[email protected]>
vstinner added a commit that referenced this pull request Sep 9, 2021
…H-28251)

Update test_sysconfig.test_user_similar() for the posix_user scheme:
"platlib" doesn't use sys.platlibdir.
(cherry picked from commit 49acac0)

Co-authored-by: Victor Stinner <[email protected]>
pablogsal pushed a commit that referenced this pull request Sep 29, 2021
…H-28251)

Update test_sysconfig.test_user_similar() for the posix_user scheme:
"platlib" doesn't use sys.platlibdir.
(cherry picked from commit 49acac0)

Co-authored-by: Victor Stinner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants