strictyaml icon indicating copy to clipboard operation
strictyaml copied to clipboard

AttributeError: 'DynamicStrictYAMLLoader' object has no attribute 'comment_handling'

Open honzajavorek opened this issue 4 years ago • 13 comments

I'm suddenly getting the following error on two different projects where I'm loading YAMLs using strictyaml. Using dependabot on both of them, so they have the latest version: strictyaml==1.4.0

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.9.5/x64/bin/pelican", line 8, in <module>
    sys.exit(main())
  File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pelican/__init__.py", line 501, in main
    pelican, settings = get_instance(args)
  File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pelican/__init__.py", line 418, in get_instance
    return cls(settings), settings
  File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pelican/__init__.py", line 60, in __init__
    signals.initialized.send(self)
  File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/blinker/base.py", line 266, in send
    return [(receiver, receiver(sender, **kwargs))
  File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/blinker/base.py", line 266, in <listcomp>
    return [(receiver, receiver(sender, **kwargs))
  File "/home/runner/work/honzajavorek.cz/honzajavorek.cz/plugins/home_appearances.py", line 39, in load_appearances
    appearances = yaml.load(path.read_text(), SCHEMA).data
  File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/strictyaml/parser.py", line 318, in load
    return generic_load(yaml_string, schema=schema, label=label)
  File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/strictyaml/parser.py", line 280, in generic_load
    document = ruamelyaml.load(yaml_string, Loader=DynamicStrictYAMLLoader)
  File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ruamel/yaml/main.py", line 1067, in load
    return loader._constructor.get_single_data()
  File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ruamel/yaml/constructor.py", line 122, in get_single_data
    return self.construct_document(node)
  File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ruamel/yaml/constructor.py", line 132, in construct_document
    for _dummy in generator:
  File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ruamel/yaml/constructor.py", line 1611, in construct_yaml_seq
    data.extend(self.construct_rt_sequence(node, data))
  File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ruamel/yaml/constructor.py", line 1322, in construct_rt_sequence
    if self.loader and self.loader.comment_handling is None:
AttributeError: 'DynamicStrictYAMLLoader' object has no attribute 'comment_handling'

The specific code where this blew up is this:

https://github.com/honzajavorek/honzajavorek.cz/blob/4eccfcbb4620f9e30477e763cf8a6b7660e73a06/plugins/home_appearances.py#L39

path = Path('./content/data/appearances.yml')
appearances = yaml.load(path.read_text(), SCHEMA).data

But as I mentioned, this has happened on a different project I maintain, too. I tried to look up the error here or at the PyYAML repo, but no luck. Anyone knows what's wrong? This code has worked previously and I made no changes to it, I suspect it exploded because of a version upgrade.

honzajavorek avatar May 31 '21 10:05 honzajavorek

I'll take a look. Thank you for raising it.

On Mon, 31 May 2021, 13:18 Honza Javorek, @.***> wrote:

I'm suddenly getting the following error on two different projects where I'm loading YAMLs using strictyaml. Using dependabot on both of them, so they have the latest version: strictyaml==1.4.0

Traceback (most recent call last): File "/opt/hostedtoolcache/Python/3.9.5/x64/bin/pelican", line 8, in sys.exit(main()) File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pelican/init.py", line 501, in main pelican, settings = get_instance(args) File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pelican/init.py", line 418, in get_instance return cls(settings), settings File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pelican/init.py", line 60, in init signals.initialized.send(self) File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/blinker/base.py", line 266, in send return [(receiver, receiver(sender, **kwargs)) File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/blinker/base.py", line 266, in return [(receiver, receiver(sender, **kwargs)) File "/home/runner/work/honzajavorek.cz/honzajavorek.cz/plugins/home_appearances.py", line 39, in load_appearances appearances = yaml.load(path.read_text(), SCHEMA).data File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/strictyaml/parser.py", line 318, in load return generic_load(yaml_string, schema=schema, label=label) File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/strictyaml/parser.py", line 280, in generic_load document = ruamelyaml.load(yaml_string, Loader=DynamicStrictYAMLLoader) File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ruamel/yaml/main.py", line 1067, in load return loader._constructor.get_single_data() File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ruamel/yaml/constructor.py", line 122, in get_single_data return self.construct_document(node) File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ruamel/yaml/constructor.py", line 132, in construct_document for _dummy in generator: File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ruamel/yaml/constructor.py", line 1611, in construct_yaml_seq data.extend(self.construct_rt_sequence(node, data)) File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ruamel/yaml/constructor.py", line 1322, in construct_rt_sequence if self.loader and self.loader.comment_handling is None: AttributeError: 'DynamicStrictYAMLLoader' object has no attribute 'comment_handling'

The specific code where this blew up is this:

https://github.com/honzajavorek/honzajavorek.cz/blob/4eccfcbb4620f9e30477e763cf8a6b7660e73a06/plugins/home_appearances.py#L39

path = Path('./content/data/appearances.yml')appearances = yaml.load(path.read_text(), SCHEMA).data

But as I mentioned, this has happened on a different project I maintain, too. I tried to look up the error here or at the PyYAML repo, but no luck. Anyone knows what's wrong? This code has worked previously and I made no changes to it, I suspect it exploded because of a version upgrade.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/crdoconnor/strictyaml/issues/151, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOJKNMWF5Z7V3XNESG7VW3TQNO57ANCNFSM452TK7IA .

crdoconnor avatar May 31 '21 10:05 crdoconnor

It might be due to the version of the dependency ruamel.yaml (a new version was released yesterday). If you need a quick fix, downgrading that might help.

I'll get on this ASAP. Thank you for raising it.

On Mon, 31 May 2021, 13:25 Colm O'Connor, @.***> wrote:

I'll take a look. Thank you for raising it.

On Mon, 31 May 2021, 13:18 Honza Javorek, @.***> wrote:

I'm suddenly getting the following error on two different projects where I'm loading YAMLs using strictyaml. Using dependabot on both of them, so they have the latest version: strictyaml==1.4.0

Traceback (most recent call last): File "/opt/hostedtoolcache/Python/3.9.5/x64/bin/pelican", line 8, in sys.exit(main()) File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pelican/init.py", line 501, in main pelican, settings = get_instance(args) File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pelican/init.py", line 418, in get_instance return cls(settings), settings File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pelican/init.py", line 60, in init signals.initialized.send(self) File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/blinker/base.py", line 266, in send return [(receiver, receiver(sender, **kwargs)) File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/blinker/base.py", line 266, in return [(receiver, receiver(sender, **kwargs)) File "/home/runner/work/honzajavorek.cz/honzajavorek.cz/plugins/home_appearances.py", line 39, in load_appearances appearances = yaml.load(path.read_text(), SCHEMA).data File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/strictyaml/parser.py", line 318, in load return generic_load(yaml_string, schema=schema, label=label) File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/strictyaml/parser.py", line 280, in generic_load document = ruamelyaml.load(yaml_string, Loader=DynamicStrictYAMLLoader) File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ruamel/yaml/main.py", line 1067, in load return loader._constructor.get_single_data() File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ruamel/yaml/constructor.py", line 122, in get_single_data return self.construct_document(node) File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ruamel/yaml/constructor.py", line 132, in construct_document for _dummy in generator: File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ruamel/yaml/constructor.py", line 1611, in construct_yaml_seq data.extend(self.construct_rt_sequence(node, data)) File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ruamel/yaml/constructor.py", line 1322, in construct_rt_sequence if self.loader and self.loader.comment_handling is None: AttributeError: 'DynamicStrictYAMLLoader' object has no attribute 'comment_handling'

The specific code where this blew up is this:

https://github.com/honzajavorek/honzajavorek.cz/blob/4eccfcbb4620f9e30477e763cf8a6b7660e73a06/plugins/home_appearances.py#L39

path = Path('./content/data/appearances.yml')appearances = yaml.load(path.read_text(), SCHEMA).data

But as I mentioned, this has happened on a different project I maintain, too. I tried to look up the error here or at the PyYAML repo, but no luck. Anyone knows what's wrong? This code has worked previously and I made no changes to it, I suspect it exploded because of a version upgrade.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/crdoconnor/strictyaml/issues/151, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOJKNMWF5Z7V3XNESG7VW3TQNO57ANCNFSM452TK7IA .

crdoconnor avatar May 31 '21 10:05 crdoconnor

Thanks for such a quick look! It's both hobby/community projects, so no rush. Let me know if there's a way I can help.

honzajavorek avatar May 31 '21 10:05 honzajavorek

Many thanks for taking a look at this. My code broke this morning with the same error message. :-)

emagnantfkh avatar May 31 '21 16:05 emagnantfkh

I'm looking at it now.

On Mon, May 31, 2021 at 5:06 PM emagnantfkh @.***> wrote:

Many thanks for taking a look at this. My code broke this morning with the same error message. :-)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/crdoconnor/strictyaml/issues/151#issuecomment-851578326, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOJKNN7WHNKA7AAIWYRMO3TQOXYFANCNFSM452TK7IA .

crdoconnor avatar May 31 '21 16:05 crdoconnor

There is a temporary fix which downgrades ruamel.yaml to version 0.17.4.

If you upgrade strictyaml to version 1.4.2 it should work.

On Mon, May 31, 2021 at 5:30 PM Colm O'Connor @.***> wrote:

I'm looking at it now.

On Mon, May 31, 2021 at 5:06 PM emagnantfkh @.***> wrote:

Many thanks for taking a look at this. My code broke this morning with the same error message. :-)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/crdoconnor/strictyaml/issues/151#issuecomment-851578326, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOJKNN7WHNKA7AAIWYRMO3TQOXYFANCNFSM452TK7IA .

crdoconnor avatar May 31 '21 17:05 crdoconnor

Thank you so very much for taking care of it! I downgraded ruamel.yaml to 0.17.4 and it seems to be working fine now.

emagnantfkh avatar May 31 '21 17:05 emagnantfkh

Awesome! ❤️

honzajavorek avatar May 31 '21 17:05 honzajavorek

As the maintainer of the python-strictyaml package in Fedora Linux, I’m keeping an eye on this issue. Obviously, a version pin won’t help distributions, but I’m sure you don’t view it as a permanent fix.

“Fortunately,” the python-ruamel-yaml package is currently a bit out of date in even the development version of Fedora, so we don’t have to deal with this issue quite yet.

musicinmybrain avatar Jun 01 '21 15:06 musicinmybrain

Thank you for maintaining that package.

Yes, it's temporary. I'm aiming to get a fix rolled out for this in the next few days.

On Tue, 1 Jun 2021, 18:52 Ben Beasley, @.***> wrote:

As the maintainer of the python-strictyaml package in Fedora Linux, I’m keeping an eye on this issue. Obviously, a version pin won’t help distributions, but I’m sure you don’t view it as a permanent fix.

“Fortunately,” the python-ruamel-yaml package is currently a bit out of date in even the development version of Fedora, so we don’t have to deal with this issue quite yet.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/crdoconnor/strictyaml/issues/151#issuecomment-852237100, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOJKNOWFJ3WYFWXYKKUXXLTQT64ZANCNFSM452TK7IA .

crdoconnor avatar Jun 01 '21 16:06 crdoconnor

Thanks for the updates. I see that ruamel.yaml is vendored/bundled in 1.4.3/1.4.4. Is bundling an older, and perhaps eventually forked, version of ruamel.yamel the long-term plan? If so, I’ll probably go ahead and package this version for Fedora and document the justification for the bundling.

On the other hand, if you’re planning to start using upstream ruamel.yaml again within the next few months, I’ll wait a while and see what happens, since we’d always rather avoid bundling when it’s at all possible to do so.

musicinmybrain avatar Jun 20 '21 02:06 musicinmybrain

No, the long term plan is to swap it out with a parser I'm building alongside a formalized spec and a set of test cases that can be used on libraries written in other languages.

This will take a bit of time though. It is not a simple task.

I don't plan on depending upon ruamel.yaml again. I tried making it work with the latest version but the latest versions diverged too much.

On Sun, 20 Jun 2021, 05:35 Ben Beasley, @.***> wrote:

Thanks for the updates. I see that ruamel.yaml is vendored/bundled in 1.4.3/1.4.4. Is bundling an older, and perhaps eventually forked, version of ruamel.yamel the long-term plan? If so, I’ll probably go ahead and package this version for Fedora and document the justification for the bundling.

On the other hand, if you’re planning to start using upstream ruamel.yaml again within the next few months, I’ll wait a while and see what happens, since we’d always rather avoid bundling when it’s at all possible to do so.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/crdoconnor/strictyaml/issues/151#issuecomment-864490625, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOJKNLU2B4JSFYGYRXBC6LTTVHWHANCNFSM452TK7IA .

crdoconnor avatar Jun 20 '21 09:06 crdoconnor

Thanks for the update! It’s a big help to know what you’re planning.

musicinmybrain avatar Jun 20 '21 12:06 musicinmybrain