[sonic-cfggen]: yaml.load() is deprecated in latest versions of PyYAML module (#3526)
From 5.1 version of PyYAML python module, yaml.load() API is deprecated. Code should be compatible to support both the versions, else error/warning messages are seen like below, 2019-07-02 08:25:35,284 – INFO: [D1] /usr/local/lib/python2.7/dist-packages/sonic_device_util.py:44: 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 commit is contained in:
parent
7988deb288
commit
bdf7d24962
@ -229,7 +229,10 @@ def main():
|
||||
|
||||
for yaml_file in args.yaml:
|
||||
with open(yaml_file, 'r') as stream:
|
||||
additional_data = yaml.load(stream)
|
||||
if yaml.__version__ >= "5.1":
|
||||
additional_data = yaml.full_load(stream)
|
||||
else:
|
||||
additional_data = yaml.load(stream)
|
||||
deep_update(data, FormatConverter.to_deserialized(additional_data))
|
||||
|
||||
for json_file in args.json:
|
||||
|
@ -42,7 +42,10 @@ def get_sonic_version_info():
|
||||
return None
|
||||
data = {}
|
||||
with open('/etc/sonic/sonic_version.yml') as stream:
|
||||
data = yaml.load(stream)
|
||||
if yaml.__version__ >= "5.1":
|
||||
data = yaml.full_load(stream)
|
||||
else:
|
||||
data = yaml.load(stream)
|
||||
return data
|
||||
|
||||
def valid_mac_address(mac):
|
||||
|
Loading…
Reference in New Issue
Block a user