Skip to content

Commit f7c38d6

Browse files
committed
fix(debugger): evaluation expressions in RFW >= 6.1 not work correctly
1 parent 013bdfd commit f7c38d6

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

packages/debugger/src/robotcode/debugger/debugger.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import pathlib
66
import re
77
import threading
8-
import traceback
98
import weakref
109
from collections import deque
1110
from enum import Enum
@@ -33,6 +32,7 @@
3332
from robot.variables import evaluate_expression
3433
from robotcode.core.event import event
3534
from robotcode.core.logging import LoggingDescriptor
35+
from robotcode.robot.utils import get_robot_version
3636

3737
from .dap_types import (
3838
Breakpoint,
@@ -61,6 +61,16 @@
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

6575
class 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)))

packages/debugger/src/robotcode/debugger/protocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def done(t: asyncio.Task[Any]) -> None:
271271
message.seq,
272272
message.command,
273273
False,
274-
error_message=Message(format=f"{type(e).__name__}: {e}", show_user=True),
274+
error_message=Message(format=f"{type(e).__name__}: {e}"),
275275
)
276276
finally:
277277
with self._received_request_lock:

0 commit comments

Comments
 (0)