Skip to content

Remove obsolete import guards around gettext in getopt and optparse #126357

Closed

Description

@tomasr8

Feature or enhancement

Proposal:

In getopt and optparse, there are import guards around gettext:

cpython/Lib/getopt.py

Lines 37 to 41 in 556dc9b

try:
from gettext import gettext as _
except ImportError:
# Bootstrapping Python: gettext's dependencies not built yet
def _(s): return s

cpython/Lib/optparse.py

Lines 89 to 100 in 556dc9b

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

Based on the original issue that added these, importing gettext directly used to cause some build issues. This does not seem to be the case anymore at least on Linux for me. I'll send a PR to see if any other platforms fail.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Activity

  1. added
    type-featureA feature request or enhancement
    buildThe build process and cross-build
    on Nov 3, 2024
  2. added a commit that references this issue on Nov 3, 2024
  3. added a commit that references this issue on Dec 8, 2024
  4. added a commit that references this issue on Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildThe build process and cross-buildtype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions