Skip to content
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

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

Closed
tomasr8 opened this issue Nov 3, 2024 · 0 comments
Closed

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

tomasr8 opened this issue Nov 3, 2024 · 0 comments
Labels
build The build process and cross-build type-feature A feature request or enhancement

Comments

@tomasr8
Copy link
Member

tomasr8 commented Nov 3, 2024

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

@tomasr8 tomasr8 added type-feature A feature request or enhancement build The build process and cross-build labels Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build The build process and cross-build type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants