From 6162329424105c9fec7a21f0ee7e4f82ffaacc60 Mon Sep 17 00:00:00 2001 From: Fabio Zadrozny Date: Thu, 22 Sep 2022 15:24:16 -0300 Subject: [PATCH] When evaluating to None in repl provide empty string instead of null. Fixes #985 --- .../pydevd/_pydevd_bundle/pydevd_comm.py | 2 +- .../pydevd/tests_python/test_debugger_json.py | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py b/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py index 163fd7abe..cf85d5da6 100644 --- a/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py +++ b/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py @@ -1219,7 +1219,7 @@ def __create_frame(): if context == 'repl' and eval_result is None: # We don't want "None" to appear when typing in the repl. body = pydevd_schema.EvaluateResponseBody( - result=None, + result='', variablesReference=0, ) diff --git a/src/debugpy/_vendored/pydevd/tests_python/test_debugger_json.py b/src/debugpy/_vendored/pydevd/tests_python/test_debugger_json.py index 810eafe8b..be8ff64f5 100644 --- a/src/debugpy/_vendored/pydevd/tests_python/test_debugger_json.py +++ b/src/debugpy/_vendored/pydevd/tests_python/test_debugger_json.py @@ -1879,6 +1879,32 @@ def additional_output_checks(writer, stdout, stderr): writer.finished_ok = True +def test_evaluate_none(case_setup, pyfile): + + @pyfile + def eval_none(): + print('TEST SUCEEDED') # break here + + with case_setup.test_file(eval_none) as writer: + json_facade = JsonFacade(writer) + + json_facade.write_launch(justMyCode=False) + + json_facade.write_set_breakpoints(writer.get_line_index_with_content('break here')) + json_facade.write_make_initial_run() + + json_hit = json_facade.wait_for_thread_stopped() + json_hit = json_facade.get_stack_as_json_hit(json_hit.thread_id) + + evaluate_response = json_facade.evaluate('None', json_hit.frame_id, context='repl') + assert evaluate_response.body.result is not None + assert evaluate_response.body.result == '' + + json_facade.write_continue() + + writer.finished_ok = True + + def test_evaluate_numpy(case_setup, pyfile): try: import numpy