Dump restor issue on empty document
ruamel.yaml is a YAML 1.2 parser/emitter for Python
Brought to you by:
anthon
The following code:
from ruamel.yaml import YAML
import io
import sys
yaml=YAML()
io = io.StringIO("# hi\n{}")
data = yaml.load(io)
yaml.dump(data, sys.stdout)
Raise the exception:
Traceback (most recent call last):
File "/home/sbrunner/workspace/deskew/test.py", line 9, in <module>
yaml.dump(data, sys.stdout)
File "/home/sbrunner/.local/lib/python3.10/site-packages/ruamel/yaml/main.py", line 567, in dump
return self.dump_all([data], stream, transform=transform)
File "/home/sbrunner/.local/lib/python3.10/site-packages/ruamel/yaml/main.py", line 577, in dump_all
self._context_manager.dump(data)
File "/home/sbrunner/.local/lib/python3.10/site-packages/ruamel/yaml/main.py", line 913, in dump
self._yaml.representer.represent(data)
File "/home/sbrunner/.local/lib/python3.10/site-packages/ruamel/yaml/representer.py", line 82, in represent
self.serializer.serialize(node)
File "/home/sbrunner/.local/lib/python3.10/site-packages/ruamel/yaml/serializer.py", line 109, in serialize
self.serialize_node(node, None, None)
File "/home/sbrunner/.local/lib/python3.10/site-packages/ruamel/yaml/serializer.py", line 226, in serialize_node
self.emitter.emit(MappingEndEvent(comment=[map_comment, end_comment]))
File "/home/sbrunner/.local/lib/python3.10/site-packages/ruamel/yaml/emitter.py", line 254, in emit
self.state()
File "/home/sbrunner/.local/lib/python3.10/site-packages/ruamel/yaml/emitter.py", line 383, in expect_document_root
self.expect_node(root=True)
File "/home/sbrunner/.local/lib/python3.10/site-packages/ruamel/yaml/emitter.py", line 451, in expect_node
force_flow_indent = not self.indents.values[-1][1]
IndexError: list index out of range
This should be fixed in 0.17.36, Thanks for reporting.