Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-40275: import locale lazily in gettext #19905

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 2 commits into from
May 14, 2020
Merged
Changes from 1 commit
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
Prev Previous commit
import locale in gettext after calling warnings.warn()
  • Loading branch information
shihai1991 committed May 5, 2020
commit 359f8f1ea6db235569a794d8495f8b2412716267
12 changes: 6 additions & 6 deletions 12 Lib/gettext.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,10 @@ def gettext(self, message):
return message

def lgettext(self, message):
import locale
import warnings
warnings.warn('lgettext() is deprecated, use gettext() instead',
DeprecationWarning, 2)
import locale
if self._fallback:
with warnings.catch_warnings():
warnings.filterwarnings('ignore', r'.*\blgettext\b.*',
Expand All @@ -297,10 +297,10 @@ 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)
import locale
if self._fallback:
with warnings.catch_warnings():
warnings.filterwarnings('ignore', r'.*\blngettext\b.*',
Expand Down Expand Up @@ -461,10 +461,10 @@ def _parse(self, fp):
transidx += 8

def lgettext(self, message):
import locale
import warnings
warnings.warn('lgettext() is deprecated, use gettext() instead',
DeprecationWarning, 2)
import locale
missing = object()
tmsg = self._catalog.get(message, missing)
if tmsg is missing:
Expand All @@ -476,10 +476,10 @@ 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)
import locale
try:
tmsg = self._catalog[(msgid1, self.plural(n))]
except KeyError:
Expand Down Expand Up @@ -669,10 +669,10 @@ 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)
import locale
codeset = _localecodesets.get(domain)
try:
with warnings.catch_warnings():
Expand All @@ -697,10 +697,10 @@ 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)
import locale
codeset = _localecodesets.get(domain)
try:
with warnings.catch_warnings():
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.