From 7ab43bffde268a192bca1aea2bbb4e3fcc7fe595 Mon Sep 17 00:00:00 2001 From: Roland Dobai Date: Wed, 11 Dec 2019 14:17:41 +0100 Subject: [PATCH] tools: Fix menuconfig for Python 3 --- tools/idf_py_actions/core_ext.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/idf_py_actions/core_ext.py b/tools/idf_py_actions/core_ext.py index 952477a451..14848e40e7 100644 --- a/tools/idf_py_actions/core_ext.py +++ b/tools/idf_py_actions/core_ext.py @@ -35,9 +35,11 @@ def action_extensions(base_actions, project_path): Menuconfig target is build_target extended with the style argument for setting the value for the environment variable. """ - # The subprocess lib cannot accept environment variables as "unicode" . This is a problem - # only in Python 2. - os.environ['MENUCONFIG_STYLE'] = style.encode(sys.getfilesystemencoding() or 'utf-8') + if sys.version_info[0] < 3: + # The subprocess lib cannot accept environment variables as "unicode". + # This encoding step is required only in Python 2. + style = style.encode(sys.getfilesystemencoding() or 'utf-8') + os.environ['MENUCONFIG_STYLE'] = style build_target(target_name, ctx, args) def fallback_target(target_name, ctx, args):