Skip to content

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
@feisuzhu
Copy link
Contributor

feisuzhu commented Mar 2, 2025

/rebase

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.

2 participants