Skip to content

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

@tomasr8

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

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