Skip to content
This repository was archived by the owner on Mar 31, 2025. It is now read-only.

Commit 307f951

Browse files
authored
Merge pull request #7 from snarfed/yaml_safe_load
use PyYAML's SafeLoader explicitly
2 parents 2d680f3 + 4b76d9f commit 307f951

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

clrenv/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
def mapping():
88
with open(find_environment_path()) as f:
9-
return yaml.load(f.read())['mapping']
9+
return yaml.safe_load(f.read())['mapping']
1010

1111
env = LazyEnv()
1212
get_env = get_env

clrenv/lazy_env.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def get_env(*mode):
4949
if not mode in _env:
5050
y = (_load_current_environment(),)
5151
upaths = find_user_environment_paths()
52-
y = tuple(yaml.load(open(p).read()) for p in upaths if os.path.isfile(p)) + y
52+
y = tuple(yaml.safe_load(open(p).read()) for p in upaths if os.path.isfile(p)) + y
5353

5454
assignments = tuple(m for m in mode if m.find('=') != -1)
5555
mode = tuple(m for m in mode if m.find('=') == -1)
@@ -68,7 +68,7 @@ def get_env(*mode):
6868
e = _merged(*dicts)
6969

7070
for k, v in overrides:
71-
for pytype in (yaml.load, eval, int, float, str):
71+
for pytype in (yaml.safe_load, eval, int, float, str):
7272
try:
7373
pyval = pytype(v)
7474
break
@@ -137,7 +137,7 @@ def _setattr_rec(d, k, v):
137137

138138
def _load_current_environment():
139139
with open(find_environment_path()) as f:
140-
environment = yaml.load(f.read())
140+
environment = yaml.safe_load(f.read())
141141
return environment
142142

143143
_kf_dict_cache = {}

0 commit comments

Comments
 (0)