diff --git a/tsconfig/tsconfig/tsconfig/tsconfig.py b/tsconfig/tsconfig/tsconfig/tsconfig.py index d0ca9c83d9..e843088e5c 100644 --- a/tsconfig/tsconfig/tsconfig/tsconfig.py +++ b/tsconfig/tsconfig/tsconfig/tsconfig.py @@ -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: