@@ -1342,9 +1342,10 @@ def internal_evaluate_expression(dbg, seq, thread_id, frame_id, expression, is_e
13421342 dbg .writer .add_command (cmd )
13431343
13441344
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 })
13481349 py_db .writer .add_command (NetCommand (CMD_RETURN , 0 , variables_response , is_json = True ))
13491350
13501351
@@ -1360,19 +1361,18 @@ def internal_set_expression_json(py_db, request, thread_id):
13601361 fmt = fmt .to_dict ()
13611362
13621363 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 ,))
13691369 return
13701370
13711371 # Ok, we have the result (could be an error), let's put it into the saved variables.
13721372 frame_tracker = py_db .suspended_frames_manager .get_frame_tracker (thread_id )
13731373 if frame_tracker is None :
13741374 # 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 ,))
13761376 return
13771377
13781378 # Now that the exec is done, get the actual value changed to return.
0 commit comments