From 04b916c8aedfe76937740a08f27021c8fd4a370b Mon Sep 17 00:00:00 2001 From: Young Date: Tue, 16 Feb 2021 15:07:14 +0000 Subject: [PATCH] safe yaml loader --- qlib/__init__.py | 2 +- qlib/utils/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qlib/__init__.py b/qlib/__init__.py index 596202061..20c2cab4a 100644 --- a/qlib/__init__.py +++ b/qlib/__init__.py @@ -147,7 +147,7 @@ def init_from_yaml_conf(conf_path, **kwargs): """ with open(conf_path) as f: - config = yaml.load(f, Loader=yaml.FullLoader) + config = yaml.load(f, Loader=yaml.SafeLoader) config.update(kwargs) default_conf = config.pop("default_conf", "client") init(default_conf, **config) diff --git a/qlib/utils/__init__.py b/qlib/utils/__init__.py index 799ab377a..f5e981c24 100644 --- a/qlib/utils/__init__.py +++ b/qlib/utils/__init__.py @@ -128,7 +128,7 @@ def parse_config(config): # Check whether config is file if os.path.exists(config): with open(config, "r") as f: - return yaml.load(f) + return yaml.load(f, Loader=yaml.SafeLoader) # Check whether the str can be parsed try: return yaml.load(config)