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

[Misc] Replace deprecated locale.getdefaultlocale() in diagnose.py #8598

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bluevisor
Copy link

Brief Summary

This PR addresses a DeprecationWarning in diagnose.py related to the use of locale.getdefaultlocale(), which is deprecated as of Python 3.15. The warning was as follows:

DeprecationWarning: ‘locale.getdefaultlocale’ is deprecated and slated for removal in Python 3.15. Use setlocale(), getencoding() and getlocale() instead.

Changes Made

  • Replaced locale.getdefaultlocale() with a combination of locale.setlocale(locale.LC_ALL, ''), locale.getlocale(), and locale.getpreferredencoding() to fetch locale and encoding information without triggering the deprecation warning.
  • Updated the code to format the output similarly to the original function.

Rationale

This change future-proofs the code by using recommended functions (getlocale() and getpreferredencoding()), ensuring compatibility with Python 3.15 and beyond.

Testing

  • Verified that the DeprecationWarning no longer appears when running diagnose.py.
  • Confirmed that the output format remains consistent with the original implementation.

@bluevisor bluevisor changed the title Replace deprecated locale.getdefaultlocale() in diagnose.py fix: replace deprecated locale.getdefaultlocale() in diagnose.py Nov 10, 2024
@bluevisor bluevisor changed the title fix: replace deprecated locale.getdefaultlocale() in diagnose.py [Fix] Replace deprecated locale.getdefaultlocale() in diagnose.py Nov 10, 2024
@bluevisor bluevisor changed the title [Fix] Replace deprecated locale.getdefaultlocale() in diagnose.py [misc] Replace deprecated locale.getdefaultlocale() in diagnose.py Nov 10, 2024
@bluevisor bluevisor changed the title [misc] Replace deprecated locale.getdefaultlocale() in diagnose.py [Misc] Replace deprecated locale.getdefaultlocale() in diagnose.py Nov 10, 2024
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.

1 participant