Skip to content
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-32139: test_strftime does not anymore modify the locale #4569

Merged
merged 2 commits into from Nov 29, 2017
Merged

bpo-32139: test_strftime does not anymore modify the locale #4569

merged 2 commits into from Nov 29, 2017

Conversation

xdegaye
Copy link
Contributor

@xdegaye xdegaye commented Nov 26, 2017

try:
import java
java.util.Locale.setDefault(java.util.Locale.US)
except ImportError:
import locale
locale.setlocale(locale.LC_TIME, 'C')
self.saved_locale = setlocale(LC_TIME)
Copy link
Member

@vstinner vstinner Nov 28, 2017

Choose a reason for hiding this comment

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

I suggest to add here:

self.addCleanup(setlocale, LC_TIME, self.saved_locale)

With that, you avoid tearDown() (which is not called if the test is interrupted by CTRL+c if I recall correctly), and you may even use a local variable instead of an attribute.

Copy link
Contributor Author

@xdegaye xdegaye Nov 29, 2017

Choose a reason for hiding this comment

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

Yes, much better. Thanks for your reviews Victor.

@xdegaye xdegaye merged commit cc55e78 into python:master Nov 29, 2017
@xdegaye xdegaye deleted the bpo-32139 branch Nov 29, 2017
@miss-islington
Copy link
Contributor

miss-islington commented Nov 29, 2017

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

@miss-islington
Copy link
Contributor

miss-islington commented Nov 29, 2017

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

@bedevere-bot
Copy link

bedevere-bot commented Nov 29, 2017

GH-4635 is a backport of this pull request to the 3.6 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 29, 2017
@bedevere-bot
Copy link

bedevere-bot commented Nov 29, 2017

GH-4636 is a backport of this pull request to the 2.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 29, 2017
xdegaye pushed a commit that referenced this pull request Nov 29, 2017
xdegaye pushed a commit that referenced this pull request Nov 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants