Skip to content
Merged
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