From eaef88b45b5e23ab2778a3b5eba783e2df04cf8a Mon Sep 17 00:00:00 2001 From: Andreas Koepf Date: Mon, 17 Mar 2025 23:13:53 +0100 Subject: [PATCH] don't pass answer value to eval --- reasoning_gym/algorithmic/number_sorting.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reasoning_gym/algorithmic/number_sorting.py b/reasoning_gym/algorithmic/number_sorting.py index 97a24745..27c17743 100644 --- a/reasoning_gym/algorithmic/number_sorting.py +++ b/reasoning_gym/algorithmic/number_sorting.py @@ -117,10 +117,10 @@ Please follow the instruction below: try: # Try to parse the user's answer as a JSON list first try: + answer = answer.replace("'", '"') user_answer = json.loads(answer) except json.JSONDecodeError: - # If JSON parsing fails, fall back to eval (with caution) - user_answer = eval(answer) + return 0.0 # JSON parsing failed if not isinstance(user_answer, list): return 0.0 @@ -159,7 +159,7 @@ Please follow the instruction below: return 0.0 return 1.0 - except Exception as e: + except Exception: # Any parsing error means the answer is incorrect return 0.0