Bug 1661814

Summary: DNF return a VectorString instead of a Python List
Product: [Fedora] Fedora Reporter: recteurlp
Component: libdnfAssignee: Daniel Mach <dmach>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: unspecified    
Version: 29CC: dmach, jmracek, rpm-software-management
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libdnf-0.31.0-6.fc29 Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-08-31 01:38:54 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description recteurlp 2018-12-23 15:20:52 UTC
Description of problem:
DNF api return a VectorString instead of a Python List

Version-Release number of selected component (if applicable):
libdnf-0.22.3-1.fc29.x86_64
dnf-4.0.9-2.fc29.noarch

How reproducible:
Always

Steps to Reproduce:
python3                                                                                                                                                                              16:13
Python 3.7.1 (default, Nov 23 2018, 10:01:49) 
[GCC 8.2.1 20181105 (Red Hat 8.2.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dnf
>>> base = dnf.Base()
>>> base.read_all_repos()
>>> base.repos['updates'].excludepkgs


Actual results:
<libdnf.module.VectorString; proxy of <Swig Object of type 'std::vector< std::string > *' at 0x7f24fa275180> >

Expected results:
[]

Additional info:
https://dnf.readthedocs.io/en/latest/api_repos.html#dnf.repo.Repo.excludepkgs The documentation state its a python list

Comment 1 Jaroslav Mracek 2019-04-16 15:44:31 UTC
Please could you provide additional information what's the problem? We tried to provide compatibility vector<string> with list by adding many functions. Please could you try the latest libdnf and provide what exactly could be improved? What we cannot do is to provide a copy of configuration values in python list, because the modification of list will not result in modification of dnf.conf object.

Comment 2 recteurlp 2019-04-16 20:50:26 UTC
Thank you for your explanation about what does vector<string>

Before the docs stated that excludepkgs was a python list therefore I assumed I could JSON serialize it.

With the migration to vector<string>, which is not JSON serializable, you have to convert it to a python list first.

It may be worth to add a word about the type used by excludepkgs/includepkgs on the docs (https://dnf.readthedocs.io/en/latest/search.html?q=vectorstring&check_keywords=yes)

Because I do not think you can provide a way to make it work with the default JSONEncoder.

Comment 3 Daniel Mach 2019-07-30 13:43:41 UTC
I've created a PR that documents the returned types.

PR: https://github.com/rpm-software-management/dnf/pull/1447

Comment 4 Fedora Update System 2019-08-14 07:24:03 UTC
FEDORA-2019-d4b6ede072 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-d4b6ede072

Comment 5 Fedora Update System 2019-08-16 20:12:23 UTC
dnf-4.2.5-4.fc29, dnf-plugins-extras-4.0.4-2.fc29, libdnf-0.31.0-6.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-d4b6ede072

Comment 6 Fedora Update System 2019-08-31 01:38:54 UTC
dnf-4.2.5-4.fc29, dnf-plugins-extras-4.0.4-2.fc29, libdnf-0.31.0-6.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.