@@ -1342,9 +1342,10 @@ def internal_evaluate_expression(dbg, seq, thread_id, frame_id, expression, is_e
1342
1342
dbg .writer .add_command (cmd )
1343
1343
1344
1344
1345
- def _set_expression_response (py_db , request , result , error_message ):
1346
- body = pydevd_schema .SetExpressionResponseBody (result = "" , variablesReference = 0 )
1347
- variables_response = pydevd_base_schema .build_response (request , kwargs = {"body" : body , "success" : False , "message" : error_message })
1345
+ def _set_expression_response (py_db , request , error_message ):
1346
+ body = pydevd_schema .SetExpressionResponseBody (value = '' )
1347
+ variables_response = pydevd_base_schema .build_response (request , kwargs = {
1348
+ 'body' :body , 'success' :False , 'message' : error_message })
1348
1349
py_db .writer .add_command (NetCommand (CMD_RETURN , 0 , variables_response , is_json = True ))
1349
1350
1350
1351
@@ -1360,19 +1361,18 @@ def internal_set_expression_json(py_db, request, thread_id):
1360
1361
fmt = fmt .to_dict ()
1361
1362
1362
1363
frame = py_db .find_frame (thread_id , frame_id )
1363
- exec_code = "%s = (%s)" % (expression , value )
1364
- result = pydevd_vars .evaluate_expression (py_db , frame , exec_code , is_exec = True )
1365
- is_error = isinstance (result , ExceptionOnEvaluate )
1366
-
1367
- if is_error :
1368
- _set_expression_response (py_db , request , result , error_message = "Error executing: %s" % (exec_code ,))
1364
+ exec_code = '%s = (%s)' % (expression , value )
1365
+ try :
1366
+ pydevd_vars .evaluate_expression (py_db , frame , exec_code , is_exec = True )
1367
+ except (Exception , KeyboardInterrupt ):
1368
+ _set_expression_response (py_db , request , error_message = 'Error executing: %s' % (exec_code ,))
1369
1369
return
1370
1370
1371
1371
# Ok, we have the result (could be an error), let's put it into the saved variables.
1372
1372
frame_tracker = py_db .suspended_frames_manager .get_frame_tracker (thread_id )
1373
1373
if frame_tracker is None :
1374
1374
# This is not really expected.
1375
- _set_expression_response (py_db , request , result , error_message = " Thread id: %s is not current thread id." % (thread_id ,))
1375
+ _set_expression_response (py_db , request , error_message = ' Thread id: %s is not current thread id.' % (thread_id ,))
1376
1376
return
1377
1377
1378
1378
# Now that the exec is done, get the actual value changed to return.
0 commit comments