pyyaml
pyyaml copied to clipboard
ValueError: invalid literal for int() raised from yaml.load
The below code results in a ValueError when yaml.load is called. I wanted to report this since it seems that when data is malformed, ConstructorErrors are typically raised. This occurs in the function construct_yaml_int at line 250 in constructor.py.
Minimized Reproducer:
import yaml
yaml.load("0x_", Loader=yaml.FullLoader)
Version Information:
7.0.0.dev0
also occurs in the current release: 6.0.2
Exception Trace:
File "/rep.py", line 2, in <module>
yaml.load("0x_", Loader=yaml.FullLoader)
File "lib/python3.9/site-packages/yaml/__init__.py", line 81, in load
return loader.get_single_data()
File "lib/python3.9/site-packages/yaml/constructor.py", line 51, in get_single_data
return self.construct_document(node)
File "lib/python3.9/site-packages/yaml/constructor.py", line 55, in construct_document
data = self.construct_object(node)
File "lib/python3.9/site-packages/yaml/constructor.py", line 100, in construct_object
data = constructor(self, node)
File "lib/python3.9/site-packages/yaml/constructor.py", line 250, in construct_yaml_int
return sign*int(value[2:], 16)
ValueError: invalid literal for int() with base 16: ''