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.
Brief Summary
This PR addresses a
DeprecationWarning
indiagnose.py
related to the use oflocale.getdefaultlocale()
, which is deprecated as of Python 3.15. The warning was as follows:Changes Made
locale.getdefaultlocale()
with a combination oflocale.setlocale(locale.LC_ALL, '')
,locale.getlocale()
, andlocale.getpreferredencoding()
to fetch locale and encoding information without triggering the deprecation warning.Rationale
This change future-proofs the code by using recommended functions (
getlocale()
andgetpreferredencoding()
), ensuring compatibility with Python 3.15 and beyond.Testing
DeprecationWarning
no longer appears when runningdiagnose.py
.