55import pathlib
66import re
77import threading
8- import traceback
98import weakref
109from collections import deque
1110from enum import Enum
3332from robot .variables import evaluate_expression
3433from robotcode .core .event import event
3534from robotcode .core .logging import LoggingDescriptor
35+ from robotcode .robot .utils import get_robot_version
3636
3737from .dap_types import (
3838 Breakpoint ,
6161 VariablePresentationHint ,
6262)
6363
64+ if get_robot_version () >= (6 , 1 ):
65+
66+ def internal_evaluate_expression (expression : str , variable_store : Any ) -> Any :
67+ return evaluate_expression (expression , variable_store )
68+
69+ else :
70+
71+ def internal_evaluate_expression (expression : str , variable_store : Any ) -> Any :
72+ return evaluate_expression (expression , variable_store .store )
73+
6474
6575class Undefined :
6676 def __str__ (self ) -> str :
@@ -516,7 +526,7 @@ def process_start_state(self, source: str, line_no: int, type: str, status: str)
516526 hit = False
517527 try :
518528 vars = EXECUTION_CONTEXTS .current .variables .current
519- hit = bool (evaluate_expression (vars .replace_string (point .condition ), vars . store ))
529+ hit = bool (internal_evaluate_expression (vars .replace_string (point .condition ), vars ))
520530 except (SystemExit , KeyboardInterrupt ):
521531 raise
522532 except BaseException :
@@ -1281,14 +1291,13 @@ def run_kw() -> Any:
12811291 else :
12821292 raise
12831293 else :
1284- result = evaluate_expression (vars .replace_string (expression ), vars . store )
1294+ result = internal_evaluate_expression (vars .replace_string (expression ), vars )
12851295
12861296 except (SystemExit , KeyboardInterrupt ):
12871297 raise
12881298 except BaseException as e :
12891299 self ._logger .exception (e )
1290- result = traceback .format_exc ()
1291- # result = e
1300+ raise
12921301
12931302 return EvaluateResult (repr (result ), repr (type (result )))
12941303
@@ -1312,7 +1321,7 @@ def set_variable(
13121321 if (name [2 :- 1 ] if self .IS_VARIABLE_RE .match (name ) else name ) not in variables :
13131322 raise NameError (f"Variable '{ name } ' not found." )
13141323
1315- evaluated_value = evaluate_expression (variables .replace_string (value ), variables . store )
1324+ evaluated_value = internal_evaluate_expression (variables .replace_string (value ), variables )
13161325 variables [name ] = evaluated_value
13171326
13181327 return SetVariableResult (repr (evaluated_value ), repr (type (value )))
0 commit comments