FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-104783: Remove locale.resetlocale() function by vstinner · Pull Request #104784 · python/cpython · GitHub

/ cpython Public

gh-104783: Remove locale.resetlocale() function - #104784

Merged
vstinner merged 2 commits into
python:mainfrom
vstinner:remove_locale
Jun 6, 2023
Merged

gh-104783: Remove locale.resetlocale() function#104784
vstinner merged 2 commits into
python:mainfrom
vstinner:remove_locale

Conversation

vstinner commented May 23, 2023
edited
Loading

Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Member Author

cc @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

vstinner commented May 23, 2023
edited
Loading

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.

vstinner commented May 23, 2023
edited
Loading

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("_", "-")

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.

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.

vstinner changed the title gh-104783: Remove locale.getdefaultlocale() gh-104783: Remove locale.resetlocale() function Jun 6, 2023
vstinner merged commit 0cb6b9b into python:main Jun 6, 2023
vstinner deleted the remove_locale branch June 6, 2023 12:55

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 :-)

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL