Skip to content

Commit 28ac9b0

Browse files
committed
Original get_changes would not report unset variables
1 parent 346cefc commit 28ac9b0

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

easybuild/tools/environment.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,14 @@ def reset_changes():
9191
get_context().clear()
9292

9393

94-
def get_changes():
94+
def get_changes(show_unset=False):
9595
"""
9696
Return tracked changes made in environment.
9797
"""
98-
return get_context()
98+
changes = get_context()
99+
if not show_unset:
100+
return {k: v for k, v in changes.items() if v is not None}
101+
return changes.copy()
99102

100103

101104
def apply_context(context=None):
@@ -127,14 +130,13 @@ def getvar(key, default='', strict=False):
127130
if val is None:
128131
if strict:
129132
raise KeyError(f"Key '{key}' is explicitly unset in the current context")
130-
else:
131-
return default
133+
return default
132134
return val
133135
else:
134136
if strict:
135-
return os._real_os.environ[key]
137+
return ORIG_OS_ENVIRON[key]
136138
else:
137-
return os._real_os.environ.get(key, default)
139+
return ORIG_OS_ENVIRON.get(key, default)
138140

139141

140142
@contextmanager

0 commit comments

Comments
 (0)