From 3f68ce6d2f347cc761f01728c9977d4fabb889f1 Mon Sep 17 00:00:00 2001 From: JinWang An Date: Mon, 28 Dec 2020 13:46:45 +0900 Subject: [PATCH] Imported Upstream version 5.1.3 --- AUTHORS | 1 + ChangeLog | 5 ++ PKG-INFO | 4 +- pbr.egg-info/PKG-INFO | 4 +- pbr.egg-info/SOURCES.txt | 1 + pbr/tests/test_util.py | 67 +++++++++++++++---- pbr/util.py | 2 +- ...lode-with-equal-sign-41bf822fa4dd0e68.yaml | 7 ++ 8 files changed, 73 insertions(+), 18 deletions(-) create mode 100644 releasenotes/notes/fix-mapping-value-explode-with-equal-sign-41bf822fa4dd0e68.yaml diff --git a/AUTHORS b/AUTHORS index 760e464..3f12dd5 100644 --- a/AUTHORS +++ b/AUTHORS @@ -11,6 +11,7 @@ Anthony Young Attila Fazekas Ben Nemec Bhuvan Arumugam +Brandon LeBlanc Brant Knudson Brian Waldon Cao Xuan Hoang diff --git a/ChangeLog b/ChangeLog index aedea6d..f4d7994 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,11 @@ CHANGES ======= +5.1.3 +----- + +* Resolve \`\`ValueError\`\` when mapping value contains a literal \`\`=\`\` + 5.1.2 ----- diff --git a/PKG-INFO b/PKG-INFO index 2527e6d..f9c769e 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,14 +1,14 @@ Metadata-Version: 2.1 Name: pbr -Version: 5.1.2 +Version: 5.1.3 Summary: Python Build Reasonableness Home-page: https://docs.openstack.org/pbr/latest/ Author: OpenStack Author-email: openstack-discuss@lists.openstack.org License: UNKNOWN Project-URL: Documentation, https://docs.openstack.org/pbr/ -Project-URL: Source Code, https://git.openstack.org/cgit/openstack-dev/pbr/ Project-URL: Bug Tracker, https://bugs.launchpad.net/pbr/ +Project-URL: Source Code, https://git.openstack.org/cgit/openstack-dev/pbr/ Description: Introduction ============ diff --git a/pbr.egg-info/PKG-INFO b/pbr.egg-info/PKG-INFO index 2527e6d..f9c769e 100644 --- a/pbr.egg-info/PKG-INFO +++ b/pbr.egg-info/PKG-INFO @@ -1,14 +1,14 @@ Metadata-Version: 2.1 Name: pbr -Version: 5.1.2 +Version: 5.1.3 Summary: Python Build Reasonableness Home-page: https://docs.openstack.org/pbr/latest/ Author: OpenStack Author-email: openstack-discuss@lists.openstack.org License: UNKNOWN Project-URL: Documentation, https://docs.openstack.org/pbr/ -Project-URL: Source Code, https://git.openstack.org/cgit/openstack-dev/pbr/ Project-URL: Bug Tracker, https://bugs.launchpad.net/pbr/ +Project-URL: Source Code, https://git.openstack.org/cgit/openstack-dev/pbr/ Description: Introduction ============ diff --git a/pbr.egg-info/SOURCES.txt b/pbr.egg-info/SOURCES.txt index 4d5239d..d4a7889 100644 --- a/pbr.egg-info/SOURCES.txt +++ b/pbr.egg-info/SOURCES.txt @@ -96,6 +96,7 @@ playbooks/legacy/pbr-installation-upstream-devstack/run.yaml releasenotes/notes/deprecate-pyN-requirements-364655c38fa5b780.yaml releasenotes/notes/deprecate-testr-nose-integration-56e3e11248d946fc.yaml releasenotes/notes/fix-global-replace-of-src-prefix-in-glob-eb850b94ca96993e.yaml +releasenotes/notes/fix-mapping-value-explode-with-equal-sign-41bf822fa4dd0e68.yaml releasenotes/notes/ignore-find-links-07cf54f465aa33a6.yaml releasenotes/notes/long-descr-content-type-f9a1003acbb8740f.yaml releasenotes/notes/remove-command-hooks-907d9c2325f306ca.yaml diff --git a/pbr/tests/test_util.py b/pbr/tests/test_util.py index 370a7de..6c490a9 100644 --- a/pbr/tests/test_util.py +++ b/pbr/tests/test_util.py @@ -23,6 +23,19 @@ from pbr.tests import base from pbr import util +def config_from_ini(ini): + config = {} + if sys.version_info >= (3, 2): + parser = configparser.ConfigParser() + else: + parser = configparser.SafeConfigParser() + ini = textwrap.dedent(six.u(ini)) + parser.readfp(io.StringIO(ini)) + for section in parser.sections(): + config[section] = dict(parser.items(section)) + return config + + class TestExtrasRequireParsingScenarios(base.BaseTestCase): scenarios = [ @@ -64,20 +77,8 @@ class TestExtrasRequireParsingScenarios(base.BaseTestCase): {} })] - def config_from_ini(self, ini): - config = {} - if sys.version_info >= (3, 2): - parser = configparser.ConfigParser() - else: - parser = configparser.SafeConfigParser() - ini = textwrap.dedent(six.u(ini)) - parser.readfp(io.StringIO(ini)) - for section in parser.sections(): - config[section] = dict(parser.items(section)) - return config - def test_extras_parsing(self): - config = self.config_from_ini(self.config_text) + config = config_from_ini(self.config_text) kwargs = util.setup_cfg_to_setup_kwargs(config) self.assertEqual(self.expected_extra_requires, @@ -89,3 +90,43 @@ class TestInvalidMarkers(base.BaseTestCase): def test_invalid_marker_raises_error(self): config = {'extras': {'test': "foo :bad_marker>'1.0'"}} self.assertRaises(SyntaxError, util.setup_cfg_to_setup_kwargs, config) + + +class TestMapFieldsParsingScenarios(base.BaseTestCase): + + scenarios = [ + ('simple_project_urls', { + 'config_text': """ + [metadata] + project_urls = + Bug Tracker = https://bugs.launchpad.net/pbr/ + Documentation = https://docs.openstack.org/pbr/ + Source Code = https://git.openstack.org/cgit/openstack-dev/pbr/ + """, # noqa: E501 + 'expected_project_urls': { + 'Bug Tracker': 'https://bugs.launchpad.net/pbr/', + 'Documentation': 'https://docs.openstack.org/pbr/', + 'Source Code': 'https://git.openstack.org/cgit/openstack-dev/pbr/', # noqa: E501 + }, + }), + ('query_parameters', { + 'config_text': """ + [metadata] + project_urls = + Bug Tracker = https://bugs.launchpad.net/pbr/?query=true + Documentation = https://docs.openstack.org/pbr/?foo=bar + Source Code = https://git.openstack.org/cgit/openstack-dev/pbr/commit/?id=hash + """, # noqa: E501 + 'expected_project_urls': { + 'Bug Tracker': 'https://bugs.launchpad.net/pbr/?query=true', + 'Documentation': 'https://docs.openstack.org/pbr/?foo=bar', + 'Source Code': 'https://git.openstack.org/cgit/openstack-dev/pbr/commit/?id=hash', # noqa: E501 + }, + }), + ] + + def test_project_url_parsing(self): + config = config_from_ini(self.config_text) + kwargs = util.setup_cfg_to_setup_kwargs(config) + + self.assertEqual(self.expected_project_urls, kwargs['project_urls']) diff --git a/pbr/util.py b/pbr/util.py index 63e913d..4c76081 100644 --- a/pbr/util.py +++ b/pbr/util.py @@ -333,7 +333,7 @@ def setup_cfg_to_setup_kwargs(config, script_args=()): elif arg in MAP_FIELDS: in_cfg_map = {} for i in split_multiline(in_cfg_value): - k, v = i.split('=') + k, v = i.split('=', 1) in_cfg_map[k.strip()] = v.strip() in_cfg_value = in_cfg_map elif arg in BOOL_FIELDS: diff --git a/releasenotes/notes/fix-mapping-value-explode-with-equal-sign-41bf822fa4dd0e68.yaml b/releasenotes/notes/fix-mapping-value-explode-with-equal-sign-41bf822fa4dd0e68.yaml new file mode 100644 index 0000000..3898587 --- /dev/null +++ b/releasenotes/notes/fix-mapping-value-explode-with-equal-sign-41bf822fa4dd0e68.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fix mapping error on values who contains a literal ``=``. Example when + setup.cfg contains content like the following project urls configuration + "project_urls = Documentation = http://foo.bar/?badge=latest". + https://bugs.launchpad.net/pbr/+bug/1817592 -- 2.34.1