Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
GH-512: Fix single-frame stack trace handling. (#513)
Browse files Browse the repository at this point in the history
(fixes #512)

The XML library we are using treats a single-item list as a single item instead of a list. This breaks on_stackTrace(). This PR fixes the problem by converting xframes to a list before checking its size.
  • Loading branch information
ericsnowcurrently committed Jun 21, 2018
1 parent 5848ac7 commit 0bffee8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ptvsd/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2198,7 +2198,7 @@ def on_pydevd_thread_suspend(self, seq, args):
vsc_tid = self.thread_map.to_vscode(pyd_tid, autogen=autogen)

with self.stack_traces_lock:
self.stack_traces[pyd_tid] = xml.thread.frame
self.stack_traces[pyd_tid] = list(xml.thread.frame)

description = None
text = None
Expand Down
30 changes: 30 additions & 0 deletions tests/highlevel/test_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,36 @@ def test_basic(self):
])
self.assert_received(self.debugger, [])

def test_one_frame(self):
with self.launched():
with self.hidden():
tid, thread = self.set_thread('x')
self.suspend(thread, CMD_THREAD_SUSPEND, *[
# (pfid, func, file, line)
(2, 'spam', 'abc.py', 10),
])
self.send_request(
threadId=tid,
)
received = self.vsc.received

self.assert_vsc_received(received, [
self.expected_response(
stackFrames=[
{
'id': 1,
'name': 'spam',
'source': {'path': 'abc.py', 'sourceReference': 0},
'line': 10,
'column': 1,
},
],
totalFrames=1,
),
# no events
])
self.assert_received(self.debugger, [])

def test_with_frame_format(self):
with self.launched():
with self.hidden():
Expand Down

0 comments on commit 0bffee8

Please sign in to comment.