Skip to content

bpo-44860: Update test_sysconfig for posix_user platlib#28235

Merged
vstinner merged 3 commits into
python:mainfrom
vstinner:platlibdir
Sep 9, 2021
Merged

bpo-44860: Update test_sysconfig for posix_user platlib#28235
vstinner merged 3 commits into
python:mainfrom
vstinner:platlibdir

Conversation

@vstinner

@vstinner vstinner commented Sep 8, 2021

Copy link
Copy Markdown
Member

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

vstinner commented Sep 8, 2021

Copy link
Copy Markdown
Member Author

@uranusjr: Would you mind to review my change?

cc @hroncok @encukou @frenzymadness

Comment thread Lib/test/test_sysconfig.py Outdated
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
Copy Markdown
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
Copy Markdown
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.

@hroncok hroncok left a comment

Copy link
Copy Markdown
Contributor

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

vstinner commented Sep 8, 2021

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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

@bedevere-bot

Copy link
Copy Markdown

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 <vstinner@python.org>
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 <vstinner@python.org>
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 <vstinner@python.org>
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