Skip to content

Commit 05b976c

Browse files
authored
Fix DeprecationWarning for locale.getdefaultlocale() in diagnose.py
1 parent e9f19b8 commit 05b976c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

python/taichi/tools/diagnose.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ def main():
1616
print(f"platform: {platform.platform()}")
1717
print(f'architecture: {" ".join(platform.architecture())}')
1818
print(f"uname: {platform.uname()}")
19-
20-
print(f'locale: {".".join(locale.getdefaultlocale())}')
19+
locale.setlocale(locale.LC_ALL, '')
20+
loc, enc = locale.getlocale(), locale.getpreferredencoding()
21+
print(f'locale: {loc[0]}.{enc if enc else loc[1]}')
2122
print(f'PATH: {os.environ.get("PATH")}')
2223
print(f"PYTHONPATH: {sys.path}")
2324
print("")

0 commit comments

Comments
 (0)