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-17659: Add locale.getfirstweekday #18142
base: main
Are you sure you want to change the base?
Conversation
Since you based your patch on the original patch, please give credit to the original author. |
Misc/NEWS.d/next/Library/2020-01-23-13-05-44.bpo-17659.UfyH00.rst
Outdated
Show resolved
Hide resolved
This allows to determine the starting day of week depending on the OS locale. Co-authored-by: Kyle McMartin <kyle@mcmartin.ca>
Using setlocale does not change Windows configuration.
@tirkarthi would you like to do a final review here? I wonder if we should add the buildbot label to make sure this compiles and works everywhere (the test also needs fr_FR locale, which may be installed on no buildbot). |
My point was around a general question on the assertion. Other than that I have less knowledge to review the PR. Feel free to skip my review. |
I think it's better to return |
Indeed it is more flexible. So I made the change. |
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase And if you don't make the requested changes, you will be poked with soft cushions! |
/* Magic constant is defined by glibc as the third value of the week | ||
* keyword of LC_TIME */ | ||
switch (week_1stday) { | ||
default: |
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.
Shouldn't default
map to None?
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.
Indeed it seems that some version of glibc under en_US does not return one of the two values.
elif platform.system() == 'Windows': | ||
self.assertEqual(locale.getfirstweekday(), 6) | ||
else: | ||
self.assertEqual(locale.getfirstweekday(), None) |
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.
Have you verified that the test passes on musl libc?
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.
I do not have access to such system.
This allows to determine the starting day of week depending on the OS
locale.
Co-authored-by: Kyle McMartin kyle@mcmartin.ca
https://bugs.python.org/issue17659