Mailing List Archive

[issue13183] pdb skips frames after hitting a breakpoint and running step
Senthil Kumaran <senthil@uthcode.com> added the comment:

Hello Xavier,

This issue required some tracing through the calls and I see the problem that you have mentioned and patch fixes the problem.

One comment on the patch, for the tests in the module, this line -

self.frame_returning = None

does not seem to have a coverage. Is there a specific significance in setting this to None and would a test help?


def dispatch_return(self, frame, arg):
if self.stop_here(frame) or frame == self.returnframe:
+ self.frame_returning = frame
self.user_return(frame, arg)
+ self.frame_returning = None
if self.quitting: raise BdbQuit
return self.trace_dispatch

Sorry for the delay, I shall commit the fix in 3.3.

----------
assignee: -> orsenthil

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue13183>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue13183] pdb skips frames after hitting a breakpoint and running step [ In reply to ]
Xavier de Gaye <xdegaye@gmail.com> added the comment:

Hi Senthil,

Thanks for your help with this issue.

self.frame_returning is both a flag to indicate that we are returning
from the current frame and a value (the current frame). We need both
as set_step() (the method invoked when the user runs the step command)
does not know the current frame and wether we are returning from the
current frame.

Here is a raw sketch of the call chain in the case where the user
types the step command on returning from the current frame (Pdb
subclasses both bdb.Bdb and cmd.Cmd):

Bdb::dispatch_return
Pdb::user_return (Bdb overriden method)
Pdb::interaction
Cmd::cmdloop
Cmd::onecmd
Pdb::do_step
Bdb::set_step

So self.frame_returning must be set to None after the call to
self.user_return() so that its value is not used in another later step
command, where we are not returning from this frame. Actually it is
more explicit and more robust to use a try-finally clause, such as:

def dispatch_return(self, frame, arg):
if self.stop_here(frame) or frame == self.returnframe:
try:
self.frame_returning = frame
self.user_return(frame, arg)
finally:
self.frame_returning = None
if self.quitting: raise BdbQuit
return self.trace_dispatch


Xavier

----------

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue13183>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue13183] pdb skips frames after hitting a breakpoint and running step [ In reply to ]
Roundup Robot <devnull@psf.upfronthosting.co.za> added the comment:

New changeset 96cb47f8142e by Senthil Kumaran in branch '3.2':
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
http://hg.python.org/cpython/rev/96cb47f8142e

New changeset 5ea23739e9ba by Senthil Kumaran in branch '2.7':
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
http://hg.python.org/cpython/rev/5ea23739e9ba

New changeset ab63e874265e by Senthil Kumaran in branch 'default':
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
http://hg.python.org/cpython/rev/ab63e874265e

----------
nosy: +python-dev

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue13183>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue13183] pdb skips frames after hitting a breakpoint and running step [ In reply to ]
Senthil Kumaran <senthil@uthcode.com> added the comment:

Hello Xavier,

Thanks for the explanation. Understood the reason for setting the frame_returning to None. The patch is committed in all python versions and the issue is fixed now. Thanks for the patch and prodding through this.

--
Senthil

----------
resolution: -> fixed
stage: -> committed/rejected
status: open -> closed

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue13183>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue13183] pdb skips frames after hitting a breakpoint and running step [ In reply to ]
Martin v. Löwis <martin@v.loewis.de> added the comment:

The test fails on Windows. Whereas on Unix, the two step commands produce this output:

-> print('1')
(Pdb) step
1
--Return--
> /net/pao/export/home/staff/loewis/work/33/bar.py(2)bar()->None
-> print('1')
(Pdb) step
--Return--
> /net/pao/export/home/staff/loewis/work/33/main.py(5)foo()->None
-> bar()
(Pdb) quit

on Windows, they produce this output:

-> print('1')
(Pdb) step
--Call--
> c:\users\martin\33\python\lib\encodings\cp850.py(18)encode()
-> def encode(self, input, final=False):
(Pdb) step
> c:\users\martin\33\python\lib\encodings\cp850.py(19)encode()
-> return codecs.charmap_encode(input,self.errors,encoding_map)[0]
(Pdb) quit

I.e. the stepping enters the print, and breaks in the codec.

Reopening the issue.

----------
nosy: +loewis
status: closed -> open

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue13183>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue13183] pdb skips frames after hitting a breakpoint and running step [ In reply to ]
Xavier de Gaye <xdegaye@gmail.com> added the comment:

My fault :(
The call to print is useless for the test, so I suggest to replace it
with a plain 'pass' statement.

----------

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue13183>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue13183] pdb skips frames after hitting a breakpoint and running step [ In reply to ]
Martin v. Löwis <martin@v.loewis.de> added the comment:

That indeed makes the test pass.

----------

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue13183>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue13183] pdb skips frames after hitting a breakpoint and running step [ In reply to ]
Roundup Robot <devnull@psf.upfronthosting.co.za> added the comment:

New changeset 3b2aa777b725 by Senthil Kumaran in branch '2.7':
fix windows test failure - issue13183
http://hg.python.org/cpython/rev/3b2aa777b725

New changeset d17ecee3f752 by Senthil Kumaran in branch '3.2':
fix windows test failure - issue13183
http://hg.python.org/cpython/rev/d17ecee3f752

New changeset 0269c592c8b1 by Senthil Kumaran in branch 'default':
fix closes issue13183 - windows test failure
http://hg.python.org/cpython/rev/0269c592c8b1

----------
status: open -> closed

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue13183>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue13183] pdb skips frames after hitting a breakpoint and running step [ In reply to ]
Senthil Kumaran <senthil@uthcode.com> added the comment:

Fixed again with replacing print with pass.

But it is strange behavior that "stepping through" enters print in Windows and does not so in Unix. What's the difference in windows that could cause this? Not sure if this was expected behavior.

----------

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue13183>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue13183] pdb skips frames after hitting a breakpoint and running step [ In reply to ]
Martin v. Löwis <martin@v.loewis.de> added the comment:

> But it is strange behavior that "stepping through" enters print in
> Windows and does not so in Unix. What's the difference in windows
> that could cause this? Not sure if this was expected behavior.

On Unix, the codec most likely is UTF-8, which is directly written
in C, i.e. doesn't support Python single-stepping.

----------

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue13183>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue13183] pdb skips frames after hitting a breakpoint and running step [ In reply to ]
Roundup Robot <devnull@psf.upfronthosting.co.za> added the comment:

New changeset 6c9ce7e34511 by Martin v. Löwis in branch 'default':
Issue #13183: Revert 0b53b70a40a0 (reenable test on windows)
http://hg.python.org/cpython/rev/6c9ce7e34511

----------

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue13183>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue13183] pdb skips frames after hitting a breakpoint and running step [ In reply to ]
Charles-François Natali <neologix@free.fr> added the comment:

All 3.2 and 2.7 buildbots are still broken:
http://python.org/dev/buildbot/all/builders/x86 OpenIndiana 3.2/builds/1080

"""
======================================================================
FAIL: test_issue13183 (test.test_pdb.PdbTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/export/home/buildbot/32bits/3.2.cea-indiana-x86/build/Lib/test/test_pdb.py", line 662, in test_issue13183
'Fail to step into the caller after a return')
AssertionError: 'main.py(5)foo()->None' not found in '-> bar()' : Fail to step into the caller after a return

----------------------------------------------------------------------
Ran 2 tests in 0.558s
"""

----------
nosy: +neologix
status: closed -> open

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue13183>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue13183] pdb skips frames after hitting a breakpoint and running step [ In reply to ]
Xavier de Gaye <xdegaye@gmail.com> added the comment:

The test has been changed in the default branch by changeset
1b174a117e19. This change replaces the assertIn by a less restrictive
assertTrue. These changes should also probably be made in 3.2 and 2.7
and hopefully this will fix the problem in 3.2 and 2.7.

The changeset 1b174a117e19 in the default branch is:

diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -604,6 +604,7 @@
filename = 'main.py'
with open(filename, 'w') as f:
f.write(textwrap.dedent(script))
+ self.addCleanup(support.unlink, filename)
cmd = [sys.executable, '-m', 'pdb', filename]
stdout = stderr = None
with subprocess.Popen(cmd, stdout=subprocess.PIPE,
@@ -660,9 +661,11 @@
"""
with open('bar.py', 'w') as f:
f.write(textwrap.dedent(bar))
+ self.addCleanup(support.unlink, 'bar.py')
stdout, stderr = self.run_pdb(script, commands)
- self.assertIn('main.py(5)foo()->None', stdout.split('\n')[-3],
- 'Fail to step into the caller after a return')
+ self.assertTrue(
+ any('main.py(5)foo()->None' in l for l in stdout.splitlines()),
+ 'Fail to step into the caller after a return')

----------

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue13183>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue13183] pdb skips frames after hitting a breakpoint and running step [ In reply to ]
Antoine Pitrou <pitrou@free.fr> added the comment:

If the failures don't get fixed, the offending commit should be reverted.

----------
nosy: +pitrou

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue13183>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue13183] pdb skips frames after hitting a breakpoint and running step [ In reply to ]
Roundup Robot <devnull@psf.upfronthosting.co.za> added the comment:

New changeset e275a9f7daa9 by Georg Brandl in branch '3.2':
#13183: backport fixes to test_pdb to 3.2 branch
http://hg.python.org/cpython/rev/e275a9f7daa9

----------

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue13183>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue13183] pdb skips frames after hitting a breakpoint and running step [ In reply to ]
Roundup Robot <devnull@psf.upfronthosting.co.za> added the comment:

New changeset 2644e4ea02d3 by Georg Brandl in branch '2.7':
#13183: backport fixes to test_pdb to 2.7 branch
http://hg.python.org/cpython/rev/2644e4ea02d3

----------

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue13183>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue13183] pdb skips frames after hitting a breakpoint and running step [ In reply to ]
Georg Brandl <georg@python.org> added the comment:

Should be fixed now.

----------
status: open -> closed

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue13183>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue13183] pdb skips frames after hitting a breakpoint and running step [ In reply to ]
Xavier de Gaye <xdegaye@gmail.com> added the comment:

Note that now that this issue is fixed, issue 14743 has become more
visible.

----------

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue13183>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue13183] pdb skips frames after hitting a breakpoint and running step [ In reply to ]
Senthil Kumaran <senthil@uthcode.com> added the comment:

> Georg Brandl <georg@python.org> added the comment:
>
> Should be fixed now.

Thanks for the commit fix, Georg. The comment on buildbot failures had
escaped my attention. Sorry for that.

----------

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue13183>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com