Skip to content

Commit

Permalink
Merge pull request #1614 from jedwards4b/eval_fix
Browse files Browse the repository at this point in the history
do not eval words - only strings with whitespace

eval on a word sometimes gives unexpected results, for example eval('long') results in
<type 'long'> avoid this by only using eval if the string contains whitespace.

Test suite: on hobart: create_test cime_developer --queue long, scripts_regression_tests.py --fast
Test baseline:
Test namelist changes:
Test status: bit for bit

Fixes #1613

User interface changes?:

Code review:
  • Loading branch information
jgfouca authored May 26, 2017
2 parents 2890518 + cf843f9 commit 21f2a20
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions scripts/lib/CIME/XML/env_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,13 @@ def get_submit_args(self, case, job):
val = case.get_resolved_value(name)

if val is not None and len(str(val)) > 0 and val != "None":
# Try to evaluate val
try:
rval = eval(val)
except:
# Try to evaluate val if it contains any whitespace
if " " in val:
try:
rval = eval(val)
except:
rval = val
else:
rval = val
# need a correction for tasks per node
if flag == "-n" and rval<= 0:
Expand Down

0 comments on commit 21f2a20

Please sign in to comment.