PBR

``ValueError`` when mapping value contains a literal ``=``.

Bug #1817592 reported by Herve Beraud
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PBR
Fix Released
Undecided
Herve Beraud

Bug Description

In Setup.cfg when a value contains a literal ``=`` the parsor is not able to correctly exploid the value since other occurrence of ``=`` can be founds (cf. following example).

Example ``setup.cfg``:
project_urls = Documentation = https://format-pipfile.readthedocs.io/en/latest/?badge=latest

Current result:
$ ./setup.py
ERROR:root:Error parsing
Traceback (most recent call last):
   File "/usr/local/lib/python3.7/site-packages/pbr/core.py", line 96, in pbr attrs = util.cfg_to_args(path, dist.script_args)
   File "/usr/local/lib/python3.7/site-packages/pbr/util.py", line 258, in cfg_to_args kwargs = setup_cfg_to_setup_kwargs(config, script_args)
   File "/usr/local/lib/python3.7/site-packages/pbr/util.py", line 336, in setup_cfg_to_setup_kwargs k, v = i.split(=)
ValueError: too many values to unpack (expected 2)
error in setup command: Error parsing /Users/brandon/src/format-pipfile/setup.cfg: ValueError: too many values to unpack (expected 2)

Changed in pbr:
assignee: nobody → Herve Beraud (herveberaud)
Changed in pbr:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to pbr (master)

Reviewed: https://review.openstack.org/625372
Committed: https://git.openstack.org/cgit/openstack-dev/pbr/commit/?id=e28fc7e8702826a5325db35472a51fec5068aff7
Submitter: Zuul
Branch: master

commit e28fc7e8702826a5325db35472a51fec5068aff7
Author: Brandon LeBlanc <email address hidden>
Date: Fri Dec 14 16:13:55 2018 -0600

    Resolve ``ValueError`` when mapping value contains a literal ``=``.

    Example ``setup.cfg``::

        project_urls =
          Documentation = https://format-pipfile.readthedocs.io/en/latest/?badge=latest

    Current result::

        $ ./setup.py
        ERROR:root:Error parsing
        Traceback (most recent call last):
          File "/usr/local/lib/python3.7/site-packages/pbr/core.py", line 96, in pbr
            attrs = util.cfg_to_args(path, dist.script_args)
          File "/usr/local/lib/python3.7/site-packages/pbr/util.py", line 258, in cfg_to_args
            kwargs = setup_cfg_to_setup_kwargs(config, script_args)
          File "/usr/local/lib/python3.7/site-packages/pbr/util.py", line 336, in setup_cfg_to_setup_kwargs
            k, v = i.split(=)
        ValueError: too many values to unpack (expected 2)
        error in setup command: Error parsing /Users/brandon/src/format-pipfile/setup.cfg: ValueError: too many values to unpack (expected 2)

    After changes::

        $ ./setup.py egg_info
        [...]
        $ grep -i project-url *.egg-info/PKG-INFO
        [...]
        Project-URL: Documentation, https://format-pipfile.readthedocs.io/en/latest/?badge=latest
        [...]

    add unit tests

        {1} pbr.tests.test_util.TestMapFieldsParsingScenarios.test_project_url_parsing(simple_project_urls) [0.034230s] ... ok
        {1} pbr.tests.test_util.TestMapFieldsParsingScenarios.test_project_url_parsing(query_parameters) [0.029791s] ... ok

    Closes-Bug: #1817592
    Change-Id: Ifd4c46111528d99dadee77d6aabed201d9e84bdb
    Signed-off-by: Brandon LeBlanc <email address hidden>

Changed in pbr:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack-dev/pbr 5.1.3

This issue was fixed in the openstack-dev/pbr 5.1.3 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.