Menu

#363 Unexpected parsing errors on invalid input

open
nobody
None
minor
bug
2020-11-13
2020-11-13
No

On certain invalid input, ruamel.yaml parses the input as valid and then later raises a nonsensical exception, rather than something derived from YAMLError. The code provided below causes a TypeError: unhashable type: 'dict', because it attempts to use a dict as the key to another dict.

This is not a serious issue on its own, but might indicate a more serious parsing bug.

from ruamel import yaml as ruamel_yaml
ryaml = ruamel_yaml.YAML(typ="safe", pure=True)

data = '?\r- b}:\r'
list(ryaml.load_all(data))

Other invalid YAML causes the same error but with lists, and the invalid YAML -_ causes a ValueError because ruamel.yaml tries to parse it as an integer.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
OSZAR »