Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modulemd.ModuleStream.read_string does not accept None for optional arguments #273

Closed
mprahl opened this issue Apr 30, 2019 · 3 comments
Closed

Comments

@mprahl
Copy link
Contributor

mprahl commented Apr 30, 2019

Modulemd.ModuleStream.read_string has two optional arguments, module_name and module_stream. When interfacing with them in Python, None values are not allowed. Empty strings do work however. Here is the reproducer:

import requests
import gi
gi.require_version("Modulemd", "2.0")
from gi.repository import Modulemd

mmd_str = requests.get(
    'https://pagure.io/fm-orchestrator/raw/master/f/tests/staged_data/platform.yaml').text
Modulemd.ModuleStream.read_string(mmd_str, None, None)

This causes the following traceback:

Traceback (most recent call last):
  File "reproducer.py", line 8, in <module>
    Modulemd.ModuleStream.read_string(mmd_str, None, None)
TypeError: Argument 1 does not allow None as a value
@sgallagher
Copy link
Collaborator

The problem here is that you are actually missing the strict argument, which is non-nullable. You probably want to do Modulemd.ModuleStream.read_string(mmd_str, False, None, None) here. (Modulemd.ModuleStream.read_string(mmd_str, False) will also work.

@sgallagher
Copy link
Collaborator

Actually, for MBS we probably want to have True there. We want False for DNF to be more tolerant, but on the packager side I think it makes sense to reject unknown values.

@mprahl
Copy link
Contributor Author

mprahl commented May 1, 2019

Thanks @sgallagher. I fixed the documentation example in #276.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants