GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-90548: Make musl test skips smarter (fixes Alpine errors) by bitdancer · Pull Request #131313 · python/cpython Conversation
|
| (b'GLIBC_2.9', ('glibc', '2.9')), | ||
| (b'libc.so.1.2.5', ('libc', '1.2.5')), | ||
| (b'libc_pthread.so.1.2.5', ('libc', '1.2.5_pthread')), | ||
| (b'/aports/main/musl/src/musl-1.2.5', ('musl', '1.2.5')), |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can you add tests on version with 2 numbers and 4 numbers? Like /aports/main/musl/src/musl-1.2 and /aports/main/musl/src/musl-1.2.5.1.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I could, but I don't believe musl will ever have such release numbers, so is it worth doing?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Parsing a binary file using a regular expression is a strange thing for me. So I prefer to have tests to make sure that the implementation is reliable. The question is more if the regex will match versions with 2 members (x.y) or 4 members (x.y.z.a), or if it only matchs version with 3 members (x.y.z).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, though the existing tests don't do that, nor do they test the no-match cases. I could add such tests, but at that point I'd want to rewrite this test method to split it up into multiple tests, and I don't think that's in scope for this PR :) I'll add the couple of extra checks, though.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| linked = support.linked_to_musl() | ||
| self.assertIsInstance(linked, bool) | ||
| self.assertIsNotNone(linked) | ||
| if support.is_wasi: |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
What about is_emscripten?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I used is_wasi as an example, but it doesn't hurt to add emscripten as well.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
The code detecting the musl version works for me on Alpine Linux: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
For my suggestions with dedents, please check them manually as I'm not entirely sure that I didn't mix tabs and spaces.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| @unittest.skipIf( | ||
| support.linked_to_musl(), | ||
| 'musl pathconf ignores the file descriptor and returns a constant', | ||
| ) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| ) | |
| ) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I prefer the style I used because it lines up better with how python's statements work (first line only is outdented, lack of outdent signals return to outer logic block). This is accepted by PEP 8, are there additional style constrains on the cpython code base these days?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I haven't seen lots of use of hanging indents in the lib. There is no additional constraints but usually we try to be consistent with the surrounding code when possible.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Btw, do we want to create an issue (maybe an umbrella one for musl issues) or do we make it a |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
There is an issue (gh-90548). I forgot the gh issue existed when I mentioned the bpo issue :( I'm not actually sure how one does the link, as I'm still coming up to speed on the "modern" way of doing development ;) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
No worries! the PR title should be |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but please fix the important typo 'musl' in binary.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| pos = 0 | ||
| while pos < len(binary): | ||
| if b'libc' in binary or b'GLIBC' in binary: | ||
| if b'libc' in binary or b'GLIBC' or 'musl' in binary: |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| if b'libc' in binary or b'GLIBC' or 'musl' in binary: | |
| if b'libc' in binary or b'GLIBC' or b'musl' in binary: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's a nasty one. The actual fix is b'GLIBC in binary or b'musl' in binary`. That's why it passed without the b...it just ran slower ;) (A lot slower, somewhat to my surprise.)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
As I said, I won't block the PR for cosmetics only though I would have aligned with the surrounding/existing code when possible.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM in general.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| libc_search = re.compile( | ||
| br'(__libc_init)' | ||
| br'|' | ||
| br'(GLIBC_([0-9.]+))' | ||
| br'|' | ||
| br'(libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)' | ||
| br'|' | ||
| br'(musl-([0-9.]+))' | ||
| br'', | ||
| re.ASCII) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
BTW, we can switch to the VERBOSE mode, which would be slightly more clear.
| libc_search = re.compile( | |
| br'(__libc_init)' | |
| br'|' | |
| br'(GLIBC_([0-9.]+))' | |
| br'|' | |
| br'(libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)' | |
| br'|' | |
| br'(musl-([0-9.]+))' | |
| br'', | |
| re.ASCII) | |
| libc_search = re.compile(br''' | |
| (__libc_init) | |
| | (GLIBC_([0-9.]+)) | |
| | (libc(_\w+)?\.so(?:\.(\d[0-9.]*))?) | |
| | (musl-([0-9.]+)) | |
| ''', | |
| re.ASCII | re.VERBOSE) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I like that.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| # emscripten (at least as far as we're concerned) and wasi use musl, | ||
| # but platform doesn't know how to get the version, so set it to zero. | ||
| if is_emscripten or is_wasi: | ||
| return (_linked_to_musl := (0, 0, 0)) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I do not think that it is necessary to use the := operator here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It is never necessary to use the := operator, so do you mean you prefer the more verbose style (which I'm fine with changing to), or am I missing something?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I prefer the more verbose style, which is also more sequential and clear.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| "musl libc issue on Emscripten, bpo-46390" | ||
| ) | ||
| @unittest.skipIf(support.linked_to_musl(), "musl libc issue, bpo-46390") | ||
| @run_with_locales('LC_TIME', 'en_US', 'fr_FR', 'de_DE', 'ja_JP', |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We can add the linked_to_musl() check in run_with_locales() and run_with_locale(). This may be non-trivial, depending on arguments, a dummy run can be supported even if no suitable locale was found. For now, the proposed change is good as is.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
This didn't cause a test failure because the broken logic caused the regex to always run...which is a lot slower.
|
I'm thinking this is not worth backporting? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I don't think that it's worth it to backport this change to stable branches. Supporting Alpine Linux can be seen as a new feature ;-) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.