-
Notifications
You must be signed in to change notification settings - Fork 575
Closed
Labels
Description
Following piece of code results in ValueError when given "._" input for PyYAML 3.12 to parse:
import sys
import yaml
try:
list(yaml.safe_load_all(sys.stdin))
except yaml.YAMLError:
passAnd is then run:
$ echo "._" | python validate-yaml.py
Traceback (most recent call last):
File "validate-yaml.py", line 5, in <module>
list(yaml.safe_load_all(sys.stdin))
File "/home/jussi/.local/lib/python2.7/site-packages/yaml/__init__.py", line 83, in load_all
yield loader.get_data()
File "/home/jussi/.local/lib/python2.7/site-packages/yaml/constructor.py", line 33, in get_data
return self.construct_document(self.get_node())
File "/home/jussi/.local/lib/python2.7/site-packages/yaml/constructor.py", line 43, in construct_document
data = self.construct_object(node)
File "/home/jussi/.local/lib/python2.7/site-packages/yaml/constructor.py", line 88, in construct_object
data = constructor(self, node)
File "/home/jussi/.local/lib/python2.7/site-packages/yaml/constructor.py", line 282, in construct_yaml_float
return sign*float(value)
ValueError: could not convert string to float: .I would expect PyYAML only to return errors of type yaml.YAMLError, as documented, so that I can avoid catching arbitrary errors from that function, as that's generally considered bad style.
Reactions are currently unavailable