Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pdbpp.Pdb.hidden_frames discrepency with IPython.core.debugger.Pdb.hidden_frames #426

Merged
merged 9 commits into from
Nov 22, 2020
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- test $(python -c 'import sys; print("%d%d" % sys.version_info[0:2])') = 37

- name: 'py39'
env: TOXENV=py39-coverage
env: TOXENV=py39-ipython-coverage
python: 3.9
- name: 'py38'
env: TOXENV=py38-coverage
Expand Down
16 changes: 8 additions & 8 deletions src/pdbpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def __init__(self, *args, **kwds):
self.tb_lineno = {} # frame --> lineno where the exception raised
self.history = []
self.show_hidden_frames = False
self.hidden_frames = []
self._hidden_frames = []

# Sticky mode.
self.sticky = self.config.sticky_by_default
Expand Down Expand Up @@ -551,7 +551,7 @@ def _custom_completer(self):
self.fancycompleter.config.readline.set_completer(old_completer)

def print_hidden_frames_count(self):
n = len(self.hidden_frames)
n = len(self._hidden_frames)
if n and self.config.show_hidden_frames_count:
plural = n > 1 and "s" or ""
print(
Expand Down Expand Up @@ -621,16 +621,16 @@ def compute_stack(self, fullstack, idx=None):
if self.show_hidden_frames:
return fullstack, idx

self.hidden_frames = []
self._hidden_frames = []
newstack = []
for frame, lineno in fullstack:
if self._is_hidden(frame):
self.hidden_frames.append((frame, lineno))
self._hidden_frames.append((frame, lineno))
else:
newstack.append((frame, lineno))
if not newstack:
newstack.append(self.hidden_frames.pop())
newidx = idx - len(self.hidden_frames)
newstack.append(self._hidden_frames.pop())
newidx = idx - len(self._hidden_frames)
return newstack, newidx

def refresh_stack(self):
Expand Down Expand Up @@ -1147,7 +1147,7 @@ def do_hf_hide(self, arg):
self.refresh_stack()

def do_hf_list(self, arg):
for frame_lineno in self.hidden_frames:
for frame_lineno in self._hidden_frames:
print(self.format_stack_entry(frame_lineno, pdb.line_prefix),
file=self.stdout)

Expand Down Expand Up @@ -1613,7 +1613,7 @@ def _print_if_sticky(self):
self._sticky_messages = []

if self.config.show_hidden_frames_count:
n = len(self.hidden_frames)
n = len(self._hidden_frames)
if n:
plural = n > 1 and "s" or ""
s += ", %d frame%s hidden" % (n, plural)
Expand Down
24 changes: 24 additions & 0 deletions testing/test_integration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import sys

import pytest


def test_integration(testdir, readline_param):
tmpdir = testdir.tmpdir
Expand Down Expand Up @@ -60,3 +62,25 @@ def test_integration(testdir, readline_param):
assert rest == b'\x1b[1@c\x1b[9D\r\n\r\x1b[?1l\x1b>'
else:
assert rest == b'c\r\n'


def test_ipython(testdir):
"""Test integration when used with IPython.

- `up` used to crash due to conflicting `hidden_frames` attribute/method.
"""
pytest.importorskip("IPython")
child = testdir.spawn(
"{} -m IPython --colors=nocolor --simple-prompt".format(
sys.executable,
)
)
child.sendline("%debug raise ValueError('my_value_error')")
child.sendline("up")
child.expect_exact("\r\nipdb++> ")
child.sendline("c")
child.expect_exact("\r\nValueError: my_value_error\r\n")
child.expect_exact("\r\nIn [2]: ")
child.sendeof()
child.sendline("y")
assert child.wait() == 0
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ envlist = py{27,34,35,36,37,38,39}, py{py,py3}
extras = testing
deps =
coverage: pytest-cov
ipython: IPython
pexpect
# For tox's --force-dep to work (https://github.com/tox-dev/tox/issues/1199).
pytest
Expand Down