8000 bpo-40275: Remove duplicate import of locale module by shihai1991 · Pull Request #19761 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-40275: Remove duplicate import of locale module #19761

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

Merged
merged 6 commits into from
May 4, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Lib/gettext.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
# find this format documented anywhere.


import locale
import os
Copy link
Member

Choose a reason for hiding this comment

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

Please write a separated PR for gettext, and keep this PR for test.support.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, I created #19905 to do this job.

import re
import sys
Expand Down Expand Up @@ -210,6 +209,7 @@ def func(n):


def _expand_lang(loc):
import locale
loc = locale.normalize(loc)
COMPONENT_CODESET = 1 << 0
COMPONENT_TERRITORY = 1 << 1
Expand Down Expand Up @@ -275,6 +275,7 @@ def gettext(self, message):
return message

def lgettext(self, message):
import locale
import warnings
warnings.warn('lgettext() is deprecated, use gettext() instead',
DeprecationWarning, 2)
Expand All @@ -296,6 +297,7 @@ def ngettext(self, msgid1, msgid2, n):
return msgid2

def lngettext(self, msgid1, msgid2, n):
import locale
import warnings
warnings.warn('lngettext() is deprecated, use ngettext() instead',
DeprecationWarning, 2)
Expand Down Expand Up @@ -459,6 +461,7 @@ def _parse(self, fp):
transidx += 8

def lgettext(self, message):
import locale
import warnings
warnings.warn('lgettext() is deprecated, use gettext() instead',
DeprecationWarning, 2)
Expand All @@ -473,6 +476,7 @@ def lgettext(self, message):
return tmsg.encode(locale.getpreferredencoding())

def lngettext(self, msgid1, msgid2, n):
import locale
import warnings
warnings.warn('lngettext() is deprecated, use ngettext() instead',
DeprecationWarning, 2)
Expand Down Expand Up @@ -665,6 +669,7 @@ def dgettext(domain, message):
return t.gettext(message)

def ldgettext(domain, message):
import locale
import warnings
warnings.warn('ldgettext() is deprecated, use dgettext() instead',
DeprecationWarning, 2)
Expand Down Expand Up @@ -692,6 +697,7 @@ def dngettext(domain, msgid1, msgid2, n):
return t.ngettext(msgid1, msgid2, n)

def ldngettext(domain, msgid1, msgid2, n):
import locale
import warnings
warnings.warn('ldngettext() is deprecated, use dngettext() instead',
DeprecationWarning, 2)
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import hashlib
import importlib
import importlib.util
import locale
import os
import platform
import re
Expand Down Expand Up @@ -2433,6 +2432,7 @@ def skip_if_buggy_ucrt_strfptime(test):
See bpo-37552 [Windows] strptime/strftime return invalid
results with UCRT version 17763.615
"""
import locale
global _buggy_ucrt
if _buggy_ucrt is None:
if(sys.platform == 'win32' and
Expand Down
2959
0