https://github.com/python/cpython/commit/ac556a2ad1213b8bb81372fe6fb762f5fcb076de
commit: ac556a2ad1213b8bb81372fe6fb762f5fcb076de
branch: main
author: Tomas R. <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2024-11-03T18:54:42+02:00
summary:
gh-126357: Remove gettext import guards (GH-126358)
files:
M Lib/getopt.py
M Lib/optparse.py
diff --git a/Lib/getopt.py b/Lib/getopt.py
index e5fd04fe12a7ee..1df5b96472a45c 100644
--- a/Lib/getopt.py
+++ b/Lib/getopt.py
@@ -34,11 +34,8 @@
__all__ = ["GetoptError","error","getopt","gnu_getopt"]
import os
-try:
- from gettext import gettext as _
-except ImportError:
- # Bootstrapping Python: gettext's dependencies not built yet
- def _(s): return s
+from gettext import gettext as _
+
class GetoptError(Exception):
opt = ''
diff --git a/Lib/optparse.py b/Lib/optparse.py
index 1c450c6fcbe3b6..04112eca37c801 100644
--- a/Lib/optparse.py
+++ b/Lib/optparse.py
@@ -75,6 +75,8 @@
import sys, os
import textwrap
+from gettext import gettext as _, ngettext
+
def _repr(self):
return "<%s at 0x%x: %s>" % (self.__class__.__name__, id(self), self)
@@ -86,19 +88,6 @@ def _repr(self):
# Id: help.py 527 2006-07-23 15:21:30Z greg
# Id: errors.py 509 2006-04-20 00:58:24Z gward
-try:
- from gettext import gettext, ngettext
-except ImportError:
- def gettext(message):
- return message
-
- def ngettext(singular, plural, n):
- if n == 1:
- return singular
- return plural
-
-_ = gettext
-
class OptParseError (Exception):
def __init__(self, msg):
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]