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

PyYAML > 3.13 introduces breakages in metabot.util.yamlutil #40

Closed
nmlorg opened this issue Mar 25, 2019 · 2 comments
Closed

PyYAML > 3.13 introduces breakages in metabot.util.yamlutil #40

nmlorg opened this issue Mar 25, 2019 · 2 comments
Assignees
Labels
cleanup Code changes that improve maintainability without changing behavior

Comments

@nmlorg
Copy link
Owner

nmlorg commented Mar 25, 2019

metabot/test_botconf.py::test_save_load FAILED
metabot/test_multibot.py::test_save_load FAILED
metabot/util/test_yamlutil.py::test_dump_simple FAILED
metabot/util/test_yamlutil.py::test_dump_load FAILED
 ...
tmpdir = local('/tmp/pytest-of-n/pytest-1/test_dump_load2')

    def test_dump_load(tmpdir):
        """Verify the dumper and loader work as expected."""
    
        tmpfile = tmpdir.join('test.yaml')
        obj = {'key': ['value', 'value']}
>       assert yamlutil.dump(tmpfile.strpath, obj) == obj

metabot/util/test_yamlutil.py:45: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
metabot/util/yamlutil.py:29: in dump
    Dumper=_SimplifyingDumper).encode('ascii')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

documents = [{'key': ['value', 'value']}], stream = <_io.StringIO object at 0x7f4ee64bcca8>, Dumper = <class 'metabot.util.yamlutil._SimplifyingDumper'>, default_style = None, default_flow_style = False, canonical = None, indent = 4, width = 200, allow_unicode = None
line_break = None, encoding = None, explicit_start = None, explicit_end = None, version = None, tags = None, sort_keys = True

    def dump_all(documents, stream=None, Dumper=Dumper,
            default_style=None, default_flow_style=False,
            canonical=None, indent=None, width=None,
            allow_unicode=None, line_break=None,
            encoding=None, explicit_start=None, explicit_end=None,
            version=None, tags=None, sort_keys=True):
        """
        Serialize a sequence of Python objects into a YAML stream.
        If stream is None, return the produced string instead.
        """
        getvalue = None
        if stream is None:
            if encoding is None:
                stream = io.StringIO()
            else:
                stream = io.BytesIO()
            getvalue = stream.getvalue
        dumper = Dumper(stream, default_style=default_style,
                default_flow_style=default_flow_style,
                canonical=canonical, indent=indent, width=width,
                allow_unicode=allow_unicode, line_break=line_break,
                encoding=encoding, version=version, tags=tags,
>               explicit_start=explicit_start, explicit_end=explicit_end, sort_keys=sort_keys)
E       TypeError: __init__() got an unexpected keyword argument 'sort_keys'

lib/python3.7/site-packages/yaml/__init__.py:274: TypeError

See also yaml/pyyaml#265.

@nmlorg nmlorg added the cleanup Code changes that improve maintainability without changing behavior label Mar 25, 2019
@nmlorg nmlorg self-assigned this Mar 25, 2019
@nmlorg nmlorg closed this as completed in 6a4367d May 15, 2019
@DataGreed
Copy link

Did you manage to solve it? I get the same problem on PyYAML 3.12 and 3.13, not sure what to do

@nmlorg
Copy link
Owner Author

nmlorg commented Nov 26, 2019

The problem I was running into is that yaml/pyyaml#254 added a new sort_keys argument to yaml.representer.BaseRepresenter, which had to be passed through my _SimplifyingDumper from yaml.dump_all (which I did in 6a4367d).

sort_keys was added in PyYAML 5.1 (which confusingly was the first release after 3.13), so if your problem exists in 3.12 and 3.13, it's probably unrelated :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Code changes that improve maintainability without changing behavior
Projects
None yet
Development

No branches or pull requests

2 participants