Skip to content

Commit ac556a2

Browse files
authored
gh-126357: Remove gettext import guards (GH-126358)
1 parent 19d9358 commit ac556a2

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

Lib/getopt.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,8 @@
3434
__all__ = ["GetoptError","error","getopt","gnu_getopt"]
3535

3636
import os
37-
try:
38-
from gettext import gettext as _
39-
except ImportError:
40-
# Bootstrapping Python: gettext's dependencies not built yet
41-
def _(s): return s
37+
from gettext import gettext as _
38+
4239

4340
class GetoptError(Exception):
4441
opt = ''

Lib/optparse.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575

7676
import sys, os
7777
import textwrap
78+
from gettext import gettext as _, ngettext
79+
7880

7981
def _repr(self):
8082
return "<%s at 0x%x: %s>" % (self.__class__.__name__, id(self), self)
@@ -86,19 +88,6 @@ def _repr(self):
8688
# Id: help.py 527 2006-07-23 15:21:30Z greg
8789
# Id: errors.py 509 2006-04-20 00:58:24Z gward
8890

89-
try:
90-
from gettext import gettext, ngettext
91-
except ImportError:
92-
def gettext(message):
93-
return message
94-
95-
def ngettext(singular, plural, n):
96-
if n == 1:
97-
return singular
98-
return plural
99-
100-
_ = gettext
101-
10291

10392
class OptParseError (Exception):
10493
def __init__(self, msg):

0 commit comments

Comments
 (0)