Skip to content

Commit 83c6208

Browse files
committed
Don't modify passed regex_subs leading to '<_sre.SRE_Pattern..>' outputs
1 parent 7123af1 commit 83c6208

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

easybuild/tools/filetools.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,9 +1487,7 @@ def apply_regex_substitutions(paths, regex_subs, backup='.orig.eb'):
14871487
else:
14881488
_log.info("Applying following regex substitutions to %s: %s", paths, regex_subs)
14891489

1490-
compiled_regex_subs = []
1491-
for regex, subtxt in regex_subs:
1492-
compiled_regex_subs.append((re.compile(regex), subtxt))
1490+
compiled_regex_subs = [(re.compile(regex), subtxt) for (regex, subtxt) in regex_subs]
14931491

14941492
for path in paths:
14951493
try:

test/framework/filetools.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,7 @@ def test_apply_regex_substitutions(self):
12081208
(r"^(FC\s*=\s*).*$", r"\1${FC}"),
12091209
(r"^(.FLAGS)\s*=\s*-O3\s-g(.*)$", r"\1 = -O2\2"),
12101210
]
1211+
regex_subs_copy = regex_subs.copy()
12111212
ft.apply_regex_substitutions(testfile, regex_subs)
12121213

12131214
expected_testtxt = '\n'.join([
@@ -1218,6 +1219,8 @@ def test_apply_regex_substitutions(self):
12181219
])
12191220
new_testtxt = ft.read_file(testfile)
12201221
self.assertEqual(new_testtxt, expected_testtxt)
1222+
# Must not have touched the list
1223+
self.assertEqual(regex_subs_copy, regex_subs)
12211224

12221225
# backup file is created by default
12231226
backup = testfile + '.orig.eb'

0 commit comments

Comments
 (0)