Skip to content

Commit

Permalink
Fixed typo variableReference -> variablesReference. Fixes microsoft#1273
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Mar 28, 2019
1 parent b65e15a commit 1653f3b
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ def internal_evaluate_expression_json(py_db, request, thread_id):

body = pydevd_schema.EvaluateResponseBody(
result=var_data['value'],
variablesReference=var_data.get('variableReference', 0),
variablesReference=var_data.get('variablesReference', 0),
type=var_data.get('type'),
presentationHint=var_data.get('presentationHint'),
namedVariables=var_data.get('namedVariables'),
Expand Down Expand Up @@ -1004,7 +1004,7 @@ def internal_set_expression_json(py_db, request, thread_id):

body = pydevd_schema.SetExpressionResponseBody(
value=var_data['value'],
variablesReference=var_data.get('variableReference', 0),
variablesReference=var_data.get('variablesReference', 0),
type=var_data.get('type'),
presentationHint=var_data.get('presentationHint'),
namedVariables=var_data.get('namedVariables'),
Expand Down Expand Up @@ -1111,11 +1111,11 @@ def internal_get_exception_details_json(dbg, request, thread_id, set_additional_
if trace_obj is not None:
for frame_id, frame, method_name, filename_in_utf8, lineno in iter_visible_frames_info(
dbg, trace_obj.tb_frame, frame_id_to_lineno):

line_text = linecache.getline(filename_in_utf8, lineno)

# Never filter out plugin frames!
if not getattr(frame, 'IS_PLUGIN_FRAME', False):
if not getattr(frame, 'IS_PLUGIN_FRAME', False):
if not dbg.in_project_scope(filename_in_utf8):
if not dbg.get_use_libraries_filter():
continue
Expand All @@ -1132,7 +1132,7 @@ def internal_get_exception_details_json(dbg, request, thread_id, set_additional_

stack_str = ''.join(traceback.format_list(frames))

# This is an extra bit of data used by Visual Studio
# This is an extra bit of data used by Visual Studio
source_path = frames[0][0] if frames else ''

# TODO: breakMode is set to always. This should be retrieved from exception
Expand Down
78 changes: 75 additions & 3 deletions src/ptvsd/_vendored/pydevd/tests_python/test_debugger_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,15 +575,34 @@ def test_evaluate_unicode(case_setup):
evaluate_response = json_facade.wait_for_response(
json_facade.write_request(EvaluateRequest(EvaluateArguments(u'\u16A0', json_hit.frameId))))

evaluate_response_body = evaluate_response.body.to_dict()

if IS_PY2:
assert evaluate_response.body.to_dict() == {
# The error can be referenced.
variables_reference = json_facade.pop_variables_reference([evaluate_response_body])

assert evaluate_response_body == {
'result': u"SyntaxError('invalid syntax', ('<string>', 1, 1, '\\xe1\\x9a\\xa0'))",
'type': u'SyntaxError',
'variablesReference': 0,
'presentationHint': {},
}

assert len(variables_reference) == 1
reference = variables_reference[0]
assert reference > 0
variables_response = json_facade.get_variables_response(reference)
child_variables = variables_response.to_dict()['body']['variables']
assert len(child_variables) == 1
assert json_facade.pop_variables_reference(child_variables)[0] > 0
assert child_variables == [{
u'type': u'SyntaxError',
u'evaluateName': u'\u16a0.result',
u'name': u'result',
u'value': u"SyntaxError('invalid syntax', ('<string>', 1, 1, '\\xe1\\x9a\\xa0'))"
}]

else:
assert evaluate_response.body.to_dict() == {
assert evaluate_response_body == {
'result': "'\u16a1'",
'type': 'str',
'variablesReference': 0,
Expand All @@ -594,6 +613,58 @@ def test_evaluate_unicode(case_setup):
writer.finished_ok = True


def test_evaluate_variable_references(case_setup):
from _pydevd_bundle._debug_adapter.pydevd_schema import EvaluateRequest
from _pydevd_bundle._debug_adapter.pydevd_schema import EvaluateArguments
with case_setup.test_file('_debugger_case_local_variables2.py') as writer:
json_facade = JsonFacade(writer)

writer.write_set_protocol('http_json')

writer.write_add_breakpoint(writer.get_line_index_with_content('Break here'))
json_facade.write_make_initial_run()

hit = writer.wait_for_breakpoint_hit()
json_hit = json_facade.get_stack_as_json_hit(hit.thread_id)

evaluate_response = json_facade.wait_for_response(
json_facade.write_request(EvaluateRequest(EvaluateArguments('variable_for_test_2', json_hit.frameId))))

evaluate_response_body = evaluate_response.body.to_dict()

variables_reference = json_facade.pop_variables_reference([evaluate_response_body])

assert evaluate_response_body == {
'type': 'set',
'result': "set(['a'])" if IS_PY2 else "{'a'}",
'presentationHint': {},
}
assert len(variables_reference) == 1
reference = variables_reference[0]
assert reference > 0
variables_response = json_facade.get_variables_response(reference)
child_variables = variables_response.to_dict()['body']['variables']

# The name for a reference in a set is the id() of the variable and can change at each run.
del child_variables[0]['name']

assert child_variables == [
{
'type': 'str',
'value': "'a'",
'presentationHint': {'attributes': ['rawString']},
},
{
'name': '__len__',
'type': 'int',
'value': '1'
}
]

writer.write_run_thread(hit.thread_id)
writer.finished_ok = True


def test_set_expression(case_setup):
from _pydevd_bundle._debug_adapter.pydevd_schema import SetExpressionRequest
from _pydevd_bundle._debug_adapter.pydevd_schema import SetExpressionArguments
Expand Down Expand Up @@ -1021,6 +1092,7 @@ def test_exception_details(case_setup):

writer.finished_ok = True


@pytest.mark.skipif(IS_JYTHON, reason='Flaky on Jython.')
def test_path_translation_and_source_reference(case_setup):

Expand Down

0 comments on commit 1653f3b

Please sign in to comment.