Skip to content

Commit

Permalink
When evaluating to None in repl provide empty string instead of null. F…
Browse files Browse the repository at this point in the history
…ixes #985
  • Loading branch information
fabioz committed Sep 26, 2022
1 parent 1dc8271 commit 761bace
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down
26 changes: 26 additions & 0 deletions src/debugpy/_vendored/pydevd/tests_python/test_debugger_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 761bace

Please sign in to comment.