-
-
Notifications
You must be signed in to change notification settings - Fork 30k
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
bpo-35389: platform.libc_ver() uses os.confstr() #10891
Conversation
Lib/platform.py
Outdated
parts = ver.split(maxsplit=1) | ||
if len(parts) == 2: | ||
return tuple(parts) | ||
except (AttributeError, ValueError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On some systems (IIRC using musl libc) os.confstr('CS_GNU_LIBC_VERSION')
fails with OSError
, so that should be caught too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I didn't know. It's now fixed.
@@ -0,0 +1,2 @@ | |||
:func:`platform.libc_ver` now uses ``os.confstr('CS_GNU_LIBC_VERSION')`` if | |||
available. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I should add that it's only used if the executable parameter is not set.
Travis CI failed because of https://bugs.python.org/issue35411 :-( I just fixed this issue, this PR should be rebase (or merged with master). |
platform.libc_ver() now uses os.confstr('CS_GNU_LIBC_VERSION') if available and the *executable* parameter is not set. The default value of the libc_ver() *executable* parameter becomes None. Quick benchmark on Fedora 29: python3 -m perf command ./python -S -c 'import platform; platform.libc_ver()' 94.9 ms +- 4.3 ms -> 33.2 ms +- 1.4 ms: 2.86x faster (-65%)
I squashed my commits and rebased my PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test overrides the existing test test_libc_ver
.
When you're done making the requested changes, leave the comment: And if you don't make the requested changes, you will be put in the comfy chair! |
I have made the requested changes; please review again. |
Thanks for making the requested changes! @serhiy-storchaka: please review the changes made to this pull request. |
Oops, I missed these tests! It's now fixed. |
platform.libc_ver() now uses os.confstr('CS_GNU_LIBC_VERSION') if
available.
Quick benchmark on Fedora 29:
python3 -m perf command ./python -S -c 'import platform; platform.libc_ver()'
94.9 ms +- 4.3 ms -> 33.2 ms +- 1.4 ms: 2.86x faster (-65%)
https://bugs.python.org/issue35389