Port deprecated locale method
https://docs.python.org/3.11/whatsnew/3.11.html#deprecated
The locale.getdefaultlocale() function is deprecated and will be removed in Python 3.13. Use locale.setlocale(), locale.getpreferredencoding(False) and locale.getlocale() functions instead.