util,python: Updated maintainers.py to fix deprecation warning
authorBobby R. Bruce <bbruce@ucdavis.edu>
Fri, 11 Dec 2020 22:09:03 +0000 (14:09 -0800)
committerBobby R. Bruce <bbruce@ucdavis.edu>
Fri, 18 Dec 2020 22:26:05 +0000 (22:26 +0000)
The following warning was being thrown:

```
util/maint/lib/maintainers.py:120: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
```

This is fixed by adding `Loader=yaml.SafeLoader` when calling
`yaml.load()`.

Change-Id: I3b79115379a45409967a8848175658ab3c13bfc7
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/38476
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
util/maint/lib/maintainers.py

index 0b29b67beb6e92b9449a2ea4f6055a23f9789af4..6dd8d268e8129d59a2c619cf2fb760eda43a1242 100644 (file)
@@ -106,7 +106,7 @@ class Maintainers(object):
 
     @classmethod
     def from_yaml(cls, yaml_str: str) -> "Maintainers":
-        return cls(yaml.load(yaml_str))
+        return cls(yaml.load(yaml_str, Loader=yaml.SafeLoader))
 
     @classmethod
     def _load_maintainers_file(cls,
@@ -117,9 +117,9 @@ class Maintainers(object):
 
         if isinstance(path_or_file, str):
             with open(path_or_file, 'r') as fin:
-                return yaml.load(fin)
+                return yaml.load(fin, Loader=yaml.SafeLoader)
         else:
-            return yaml.load(path_or_file)
+            return yaml.load(path_or_file, Loader=yaml.SafeLoader)
 
     @classmethod
     def _parse_subsystem(cls, tag: str, ydict: Mapping[str, Any]) -> Subsystem: