Skip to content

Commit a3d6be7

Browse files
committed
fixup: kconfiglib exception on vscode terminal
For the vscode terminal on remote server, there is a chance that the client language is not identical to server. And this will cause the language required is not supported by server environment. Finally, we will see an exception occurred with kconfiglib. See RT-Thread/rt-thread#8843.
1 parent 83da004 commit a3d6be7

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

cmds/cmd_menuconfig.py

+13
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,18 @@ def mk_rtconfig(filename):
172172
rtconfig.close()
173173

174174

175+
# fix locale for kconfiglib
176+
def kconfiglib_fix_locale():
177+
import os
178+
import locale
179+
180+
# Get the list of supported locales
181+
supported_locales = set(locale.locale_alias.keys())
182+
183+
# Check if LANG is set and its value is not in the supported locales
184+
if 'LANG' in os.environ and os.environ['LANG'] not in supported_locales:
185+
os.environ['LANG'] = 'C'
186+
175187
def cmd(args):
176188
import menuconfig
177189
import defconfig
@@ -236,6 +248,7 @@ def cmd(args):
236248
defconfig.main()
237249
else:
238250
sys.argv = ['menuconfig', 'Kconfig']
251+
kconfiglib_fix_locale()
239252
menuconfig._main()
240253

241254
if os.path.isfile(".config"):

0 commit comments

Comments
 (0)