[libc-commits] [libc] [libc] move newheadergen back to safe_load (PR #105374)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Tue Aug 20 14:01:36 PDT 2024


https://github.com/michaelrj-google created https://github.com/llvm/llvm-project/pull/105374

In #100024 we moved from safe_load to load for reading the yaml in
newheadergen due to dependency issues. Those should be resolved by now
so this should be a simple safety improvement.


>From 7da3dc417aca49e4fea9de5206422aaed4d259f7 Mon Sep 17 00:00:00 2001
From: Michael Jones <michaelrj at google.com>
Date: Tue, 20 Aug 2024 14:00:12 -0700
Subject: [PATCH] [libc] move newheadergen back to safe_load

In #100024 we moved from safe_load to load for reading the yaml in
newheadergen due to dependency issues. Those should be resolved by now
so this should be a simple safety improvement.
---
 libc/newhdrgen/yaml_to_classes.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libc/newhdrgen/yaml_to_classes.py b/libc/newhdrgen/yaml_to_classes.py
index 3eb5e4ef2546c1..237dd21aa5dff5 100644
--- a/libc/newhdrgen/yaml_to_classes.py
+++ b/libc/newhdrgen/yaml_to_classes.py
@@ -118,7 +118,7 @@ def load_yaml_file(yaml_file, header_class, entry_points):
         HeaderFile: An instance of HeaderFile populated with the data.
     """
     with open(yaml_file, "r") as f:
-        yaml_data = yaml.load(f, Loader=yaml.FullLoader)
+        yaml_data = yaml.safe_load(f)
     return yaml_to_classes(yaml_data, header_class, entry_points)
 
 
@@ -173,7 +173,7 @@ def add_function_to_yaml(yaml_file, function_details):
     new_function = parse_function_details(function_details)
 
     with open(yaml_file, "r") as f:
-        yaml_data = yaml.load(f, Loader=yaml.FullLoader)
+        yaml_data = yaml.safe_load(f)
     if "functions" not in yaml_data:
         yaml_data["functions"] = []
 



More information about the libc-commits mailing list