Skip to content

Commit 8a422a1

Browse files
committed
Fix get runtime language code
解决在 Windows 平台获取的语言编码不符合 RFC1766 的问题;
1 parent 4646bbc commit 8a422a1

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/py2exe_gui/Core/runtime_info.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
运行时信息
66
"""
77

8-
from locale import LC_CTYPE, getlocale
8+
from locale import getdefaultlocale
99
from typing import NamedTuple, Optional
1010

1111
from ..Constants import PLATFORM, get_platform
@@ -16,4 +16,7 @@ class RuntimeInfo(NamedTuple):
1616
language_code: Optional[str]
1717

1818

19-
RUNTIME_INFO = RuntimeInfo(get_platform(), getlocale(category=LC_CTYPE)[0])
19+
# 虽然 locale.getdefaultlocale() 函数已被废弃[https://github.com/python/cpython/issues/90817],
20+
# 但仍然是目前唯一能在 Windows 平台正确获取语言编码的方式[https://github.com/python/cpython/issues/82986]
21+
# 当 Python 更新修复了这一问题后,将迁移至 locale.getlocale()
22+
RUNTIME_INFO = RuntimeInfo(get_platform(), getdefaultlocale()[0]) # noqa

0 commit comments

Comments
 (0)