GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-104783: Remove locale.resetlocale() function by vstinner · Pull Request #104784 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented May 23, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: Remove locale.resetlocale() function in Python 3.13 #104783

📚 Documentation preview 📚: https://cpython-previews--104784.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added the awaiting core review label May 23, 2023
@bedevere-bot bedevere-bot mentioned this pull request May 23, 2023
Remove locale.resetlocale() function in Python 3.13 #104783
Closed
@vstinner
vstinner force-pushed the remove_locale branch from 1ecd49a to 099fbf5 Compare May 23, 2023 02:06
@vstinner

vstinner commented May 23, 2023

Copy link
Copy Markdown
Member Author

cc @methane

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
vstinner force-pushed the remove_locale branch from 099fbf5 to 1bce4d9 Compare May 23, 2023 02:31
@methane

methane commented May 23, 2023

Copy link
Copy Markdown
Member

I am a bit afraid to remove the API since many projects are still using it.
How about waiting 3 more years? Or how about make it alias to locale.getlocale()?

https://sourcegraph.com/search?q=locale.getdefaultlocale+lang%3Apython&patternType=standard&sm=1&groupBy=repo

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented May 23, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Using resetlocale regex, I only found one project in PyPI top 5,000 projects (2023-04-13) using locale.resetlocale(): shapely (2.0.1).

shapely-2.0.1/tests/test_locale.py: locale.resetlocale()

EDIT: I ignored pylint since I don't think that it's affected.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented May 23, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Using getdefaultlocale regex, I found the following projects in PyPI top 5,000 projects (2023-04-13) using locale.getdefaultlocale().

Affected projects (34):

  • Pint (0.20.1)
  • PyQt5 (5.15.9)
  • anyconfig (0.13.0)
  • anytemplate (0.1.6)
  • apache-airflow (2.5.3)
  • applicationinsights (0.11.10)
  • apprise (1.3.0)
  • awsebcli (3.20.5)
  • azure-cli-core (2.47.0)
  • azure-monitor-opentelemetry-exporter-1.0.0b13
  • docutils (0.19)
  • edk2-pytool-library (0.14.1)
  • elementpath (4.1.1)
  • future (0.18.3)
  • googleads (37.0.0)
  • gsutil (5.23)
  • hachoir (3.2.0)
  • l18n (2021.3)
  • micloud (0.6)
  • nibabel (5.1.0)
  • nltk (3.8.1)
  • numba (0.56.4)
  • opencensus-ext-azure (1.1.9)
  • os_sys (2.1.4)
  • oslo.i18n (6.0.0)
  • pipenv (2023.3.20)
  • pyenchant (3.2.2)
  • pyramid (2.0.1)
  • pytest-nunit (1.0.3)
  • rabbitpy (2.0.1)
  • tabcmd (2.0.11)
  • tables (3.8.0)
  • teamcity-messages (1.32)
  • undetected-chromedriver (3.4.6)
Details Code:
Pint-0.20.1.tar.gz: Pint-0.20.1/pint/facets/plain/registry.py: loc = locale.getdefaultlocale()[0]
PyQt5-5.15.9.tar.gz: PyQt5-5.15.9/pylupdate/pylupdate_main.py: return path.encode(locale.getdefaultlocale()[1])
PyQt5-5.15.9.tar.gz: PyQt5-5.15.9/sip/pylupdate/pylupdate_main.py: return path.encode(locale.getdefaultlocale()[1])
anyconfig-0.13.0.tar.gz: anyconfig-0.13.0/src/anyconfig/cli/io.py: encoding = (locale.getdefaultlocale()[1] or 'UTF-8').lower()
anytemplate-0.1.6.tar.gz: anytemplate-0.1.6/src/anytemplate/compat.py: ENCODING = locale.getdefaultlocale()[1] or "UTF-8"
apache-airflow-2.5.3.tar.gz: apache-airflow-2.5.3/airflow/cli/commands/info_command.py: _locale = locale.getdefaultlocale()
applicationinsights-0.11.10.tar.gz: applicationinsights-0.11.10/applicationinsights/channel/TelemetryContext.py: self.locale = locale.getdefaultlocale()[0]
applicationinsights-0.11.10.tar.gz: applicationinsights-0.11.10/tests/applicationinsights_tests/channel_tests/TestTelemetryContext.py: self.assertEqual(locale.getdefaultlocale()[0], context.device.locale)
apprise-1.3.0.tar.gz: apprise-1.3.0/apprise/AppriseLocale.py: lang = locale.getdefaultlocale()[0]
apprise-1.3.0.tar.gz: apprise-1.3.0/test/test_locale.py: @mock.patch('locale.getdefaultlocale')
awsebcli-3.20.5.tar.gz: awsebcli-3.20.5/ebcli/bundled/asciimatics/screen.py: encoding = getdefaultlocale()[1]
awsebcli-3.20.5.tar.gz: awsebcli-3.20.5/ebcli/bundled/asciimatics/screen.py: from locale import getlocale, getdefaultlocale
azure-cli-core-2.47.0.tar.gz: azure-cli-core-2.47.0/azure/cli/core/telemetry.py: lambda: '{},{}'.format(locale.getdefaultlocale()[0], locale.getdefaultlocale()[1]))
azure-monitor-opentelemetry-exporter-1.0.0b13.zip: azure-monitor-opentelemetry-exporter-1.0.0b13/azure/monitor/opentelemetry/exporter/_utils.py: "ai.device.locale": locale.getdefaultlocale()[0],
docutils-0.19.tar.gz: docutils-0.19/docutils/io.py: _locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
docutils-0.19.tar.gz: docutils-0.19/docutils/utils/smartquotes.py: defaultlanguage = locale.getdefaultlocale()[0]
edk2-pytool-library-0.14.1.tar.gz: edk2-pytool-library-0.14.1/edk2toollib/utility_functions.py: (_, encoding) = locale.getdefaultlocale()
elementpath-4.1.1.tar.gz: elementpath-4.1.1/elementpath/collations.py: of locale.getdefaultlocale(), deprecated since Python 3.11.
future-0.18.3.tar.gz: future-0.18.3/docs/3rd-party-py3k-compat-code/django_utils_encoding.py: encoding = locale.getdefaultlocale()[1] or 'ascii'
googleads-37.0.0.tar.gz: googleads-37.0.0/googleads/common.py: _, encoding = locale.getdefaultlocale()
gsutil-5.23.tar.gz: gsutil-5.23/gslib/utils/system_util.py: IS_CP1252 = locale.getdefaultlocale()[1] == WINDOWS_1252
hachoir-3.2.0.tar.gz: hachoir-3.2.0/hachoir/wx/unicode.py: charset = locale.getdefaultlocale()[1]
l18n-2021.3.tar.gz: l18n-2021.3/PKG-INFO: ``locale.getdefaultlocale()``). If it is not the one you want or if you need to
l18n-2021.3.tar.gz: l18n-2021.3/l18n.egg-info/PKG-INFO: ``locale.getdefaultlocale()``). If it is not the one you want or if you need to
l18n-2021.3.tar.gz: l18n-2021.3/l18n/translation.py: from locale import getdefaultlocale
l18n-2021.3.tar.gz: l18n-2021.3/l18n/translation.py: self.set(getdefaultlocale()[0])
micloud-0.6.tar.gz: micloud-0.6/micloud/micloud.py: self.locale = locale.getdefaultlocale()[0]
nibabel-5.1.0.tar.gz: nibabel-5.1.0/nibabel/cmdline/dicomfs.py: encoding = locale.getdefaultlocale()[1]
nltk-3.8.1.zip: nltk-3.8.1/nltk/util.py: encodings.append(locale.getdefaultlocale()[1])
numba-0.56.4.tar.gz: numba-0.56.4/numba/misc/numba_sysinfo.py: locale.getdefaultlocale()])
opencensus-ext-azure-1.1.9.tar.gz: opencensus-ext-azure-1.1.9/opencensus/ext/azure/common/utils.py: 'ai.device.locale': locale.getdefaultlocale()[0],
os_sys-2.1.4.tar.gz: os_sys-2.1.4/edit/iomenu.py: locale_encoding = locale.getdefaultlocale()[1]
os_sys-2.1.4.tar.gz: os_sys-2.1.4/edit/iomenu.py: locale_encoding = locale.getdefaultlocale()[1]
os_sys-2.1.4.tar.gz: os_sys-2.1.4/server/utils/encoding.py: encoding = locale.getdefaultlocale()[1] or 'ascii'
oslo.i18n-6.0.0.tar.gz: oslo.i18n-6.0.0/oslo_i18n/_message.py: system_locale = locale.getdefaultlocale()
oslo.i18n-6.0.0.tar.gz: oslo.i18n-6.0.0/oslo_i18n/fixture.py: self.useFixture(fixtures.MonkeyPatch('locale.getdefaultlocale',
oslo.i18n-6.0.0.tar.gz: oslo.i18n-6.0.0/oslo_i18n/tests/test_message.py: @mock.patch('locale.getdefaultlocale')
oslo.i18n-6.0.0.tar.gz: oslo.i18n-6.0.0/oslo_i18n/tests/test_message.py: @mock.patch('locale.getdefaultlocale')
oslo.i18n-6.0.0.tar.gz: oslo.i18n-6.0.0/oslo_i18n/tests/test_message.py: @mock.patch('locale.getdefaultlocale', return_value=('es', ''))
oslo.i18n-6.0.0.tar.gz: oslo.i18n-6.0.0/oslo_i18n/tests/test_message.py: mock_getdefaultlocale):
oslo.i18n-6.0.0.tar.gz: oslo.i18n-6.0.0/oslo_i18n/tests/test_message.py: mock_getdefaultlocale):
oslo.i18n-6.0.0.tar.gz: oslo.i18n-6.0.0/oslo_i18n/tests/test_message.py: mock_getdefaultlocale.return_value = ('es',)
oslo.i18n-6.0.0.tar.gz: oslo.i18n-6.0.0/oslo_i18n/tests/test_message.py: mock_getdefaultlocale.return_value = ('es',)
pipenv-2023.3.20.tar.gz: pipenv-2023.3.20/pipenv/vendor/vistir/misc.py: locale_encoding = locale.getdefaultlocale()[1] or "ascii"
pyenchant-3.2.2.tar.gz: pyenchant-3.2.2/enchant/utils.py: tag = locale.getdefaultlocale()[0]
pyramid-2.0.1.tar.gz: pyramid-2.0.1/tests/test_integration.py: defaultlocale = locale.getdefaultlocale()[1]
pytest-nunit-1.0.3.tar.gz: pytest-nunit-1.0.3/pytest_nunit/nunit.py: language_code = locale.getdefaultlocale()[0]
rabbitpy-2.0.1.tar.gz: rabbitpy-2.0.1/rabbitpy/channel0.py: DEFAULT_LOCALE = locale.getdefaultlocale()
tabcmd-2.0.11.tar.gz: tabcmd-2.0.11/tabcmd/execution/localize.py: current_locale, encoding = locale.getdefaultlocale()
tables-3.8.0.tar.gz: tables-3.8.0/tables/tests/common.py: print('Default locale:      (%s, %s)' % locale.getdefaultlocale())
teamcity-messages-1.32.tar.gz: teamcity-messages-1.32/teamcity/common.py: loc = locale.getdefaultlocale()
undetected-chromedriver-3.4.6.tar.gz: undetected-chromedriver-3.4.6/undetected_chromedriver/__init__.py: language = locale.getdefaultlocale()[0].replace("_", "-")
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented May 23, 2023

Copy link
Copy Markdown
Member Author

I am a bit afraid to remove the API since many projects are still using it.

If we decide to keep these functions, I suggest at least to update their deprecation documentation.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@methane

methane commented May 23, 2023

Copy link
Copy Markdown
Member

Using resetlocale regex, I only found one project in PyPI top 5,000 projects (2023-04-13) using locale.resetlocale(): shapely (2.0.1).

I agree that resetlocale is minor enough to removal.

I am a bit afraid to remove the API since many projects are still using it.

If we decide to keep these functions, I suggest at least to update their deprecation documentation.

Of course.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gpshead @vstinner
pythongh-104783: Remove locale.resetlocale() function
06e28a7
@vstinner
vstinner force-pushed the remove_locale branch from 1bce4d9 to 06e28a7 Compare June 6, 2023 10:17
@vstinner vstinner changed the title gh-104783: Remove locale.getdefaultlocale() gh-104783: Remove locale.resetlocale() function Jun 6, 2023
@vstinner
Fix typo
92edb15
@vstinner
vstinner merged commit 0cb6b9b into python:main Jun 6, 2023
@vstinner
vstinner deleted the remove_locale branch June 6, 2023 12:55
@bedevere-bot bedevere-bot removed the awaiting core review label Jun 6, 2023
@vstinner

vstinner commented Jun 6, 2023

Copy link
Copy Markdown
Member Author

Ok, let's start with removing locale.resetlocale(). The locale.getdefaultlocale() function can stay a little bit longer thanks to @methane :-)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hugovk hugovk mentioned this pull request Oct 22, 2023
Postpone removal version for locale.getdefaultlocale() #111187
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@vstinner @methane @bedevere-bot @gpshead
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.