scripts: dts: gen_driver_kconfig_dts: Use SafeLoader

Using SafeLoader is preferrable where possible.

Signed-off-by: Moritz Fischer <moritzf@google.com>
This commit is contained in:
Moritz Fischer 2022-12-20 09:01:19 -08:00 committed by Marti Bolivar
commit 7dd05967f7

View file

@ -12,9 +12,9 @@ import re
import yaml import yaml
try: try:
# Use the C LibYAML parser if available, rather than the Python parser. # Use the C LibYAML parser if available, rather than the Python parser.
from yaml import CLoader as Loader from yaml import CSafeLoader as SafeLoader
except ImportError: except ImportError:
from yaml import Loader # type: ignore from yaml import SafeLoader # type: ignore
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'python-devicetree', sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'python-devicetree',
'src')) 'src'))
@ -75,7 +75,7 @@ def main():
try: try:
# Parsed PyYAML output (Python lists/dictionaries/strings/etc., # Parsed PyYAML output (Python lists/dictionaries/strings/etc.,
# representing the file) # representing the file)
raw = yaml.load(contents, Loader=Loader) raw = yaml.load(contents, Loader=SafeLoader)
except yaml.YAMLError as e: except yaml.YAMLError as e:
print(f"WARNING: '{binding_path}' appears in binding " print(f"WARNING: '{binding_path}' appears in binding "
f"directories but isn't valid YAML: {e}") f"directories but isn't valid YAML: {e}")