tsconfig: Fix py3 compatibility

Fix config parser different behavior between python versions.

Story: 2006796
Task: 42589
Signed-off-by: Dan Voiculeasa <dan.voiculeasa@windriver.com>
Change-Id: I42ce873a86d38900d433a28c72b328950c3e078d
This commit is contained in:
Dan Voiculeasa 2021-06-08 17:54:24 +03:00
parent 75758b37a5
commit 0bf05fafc7
1 changed files with 16 additions and 4 deletions

View File

@ -1,14 +1,16 @@
"""
Copyright (c) 2014-2019 Wind River Systems, Inc.
Copyright (c) 2014-2021 Wind River Systems, Inc.
SPDX-License-Identifier: Apache-2.0
"""
import os
from six.moves import configparser
import io
import logging
import os
import six
from six.moves import configparser
SW_VERSION = ""
SW_VERSION_20_06 = "20.06"
@ -56,7 +58,17 @@ def _load():
ini_str = u'[build_info]\n' + open(build_info, 'r').read()
ini_fp = io.StringIO(ini_str)
config = configparser.SafeConfigParser()
# In python3 configparser uses strict mode by default. It doesn't
# agree duplicate keys, and will throw an error
# In python2 the strict argument is missing
# TODO(dvoicule): the logic branching here can be removed once
# https://bugs.launchpad.net/starlingx/+bug/1931529 is fixed, allowing
# python3 parser to work in strict mode.
if six.PY2:
config = configparser.SafeConfigParser()
elif six.PY3:
config = configparser.SafeConfigParser(strict=False)
config.readfp(ini_fp)
try: