Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-111744: Makebreakpoint() enter the debugger immediately#118579

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
brandtbucher merged 6 commits intopython:mainfromgaogaotiantian:pdb-breakpoint
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletionsDoc/library/pdb.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,8 +62,8 @@ running without the debugger using the :pdbcmd:`continue` command.

The debugger's prompt is ``(Pdb)``, which is the indicator that you are in debug mode::

> ...(3)double()
->return x * 2
> ...(2)double()
->breakpoint()
(Pdb) p x
3
(Pdb) continue
Expand DownExpand Up@@ -164,6 +164,9 @@ slightly different way:
.. versionchanged:: 3.7
The keyword-only argument *header*.

.. versionchanged:: 3.13
:func:`set_trace` will enter the debugger immediately after the call,
rather than before the next line of code is executed.

.. function:: post_mortem(traceback=None)

Expand Down
4 changes: 4 additions & 0 deletionsDoc/whatsnew/3.13.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -710,6 +710,10 @@ pdb
* :mod:`zipapp` is supported as a debugging target.
(Contributed by Tian Gao in :gh:`118501`.)

* ``breakpoint()`` and ``pdb.set_trace()`` now enter the debugger immediately
after the call rather than before the next line is executed.
(Contributed by Tian Gao in :gh:`118579`.)

queue
-----

Expand Down
2 changes: 1 addition & 1 deletionLib/bdb.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -378,7 +378,7 @@ def set_trace(self, frame=None):
# We need f_trace_lines == True for the debugger to work
frame.f_trace_lines=True
frame=frame.f_back
self.set_step()
self.set_stepinstr()
sys.settrace(self.trace_dispatch)

defset_continue(self):
Expand Down
2 changes: 2 additions & 0 deletionsLib/pdb.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -431,6 +431,8 @@ def user_line(self, frame):
ifself.bp_commands(frame):
self.interaction(frame,None)

user_opcode=user_line

defbp_commands(self,frame):
"""Call every command that was set for the current active breakpoint
(if there is one).
Expand Down
14 changes: 10 additions & 4 deletionsLib/test/test_doctest/test_doctest.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2056,8 +2056,7 @@ def test_pdb_set_trace():
>>> try: runner.run(test)
... finally: sys.stdin = real_stdin
--Return--
> <doctest foo-bar@baz[2]>(1)<module>()->None
> <doctest foo-bar@baz[2]>(1)<module>()
-> import pdb; pdb.set_trace()
(Pdb) print(x)
42
Expand DownExpand Up@@ -2087,8 +2086,7 @@ def test_pdb_set_trace():
... runner.run(test)
... finally:
... sys.stdin = real_stdin
--Return--
> <doctest test.test_doctest.test_doctest.test_pdb_set_trace[9]>(3)calls_set_trace()->None
> <doctest test.test_doctest.test_doctest.test_pdb_set_trace[9]>(3)calls_set_trace()
-> import pdb; pdb.set_trace()
(Pdb) print(y)
2
Expand All@@ -2114,6 +2112,7 @@ def test_pdb_set_trace():
>>> test = parser.get_doctest(doc, globals(), "foo-bar@baz", "foo-bar@baz.py", 0)
>>> real_stdin = sys.stdin
>>> sys.stdin = FakeInput([
... 'step', # return event of g
... 'list', # list source from example 2
... 'next', # return from g()
... 'list', # list source from example 1
Expand All@@ -2124,6 +2123,9 @@ def test_pdb_set_trace():
>>> try: runner.run(test)
... finally: sys.stdin = real_stdin
... # doctest: +NORMALIZE_WHITESPACE
> <doctest foo-bar@baz[1]>(3)g()
-> import pdb; pdb.set_trace()
(Pdb) step
--Return--
> <doctest foo-bar@baz[1]>(3)g()->None
-> import pdb; pdb.set_trace()
Expand DownExpand Up@@ -2188,6 +2190,7 @@ def test_pdb_set_trace_nested():
>>> test = parser.get_doctest(doc, globals(), "foo-bar@baz", "foo-bar@baz.py", 0)
>>> real_stdin = sys.stdin
>>> sys.stdin = FakeInput([
... 'step',
... 'print(y)', # print data defined in the function
... 'step', 'step', 'step', 'step', 'step', 'step', 'print(z)',
... 'up', 'print(x)',
Expand All@@ -2201,6 +2204,9 @@ def test_pdb_set_trace_nested():
... finally:
... sys.stdin = real_stdin
... # doctest: +REPORT_NDIFF
> <doctest test.test_doctest.test_doctest.test_pdb_set_trace_nested[0]>(4)calls_set_trace()
-> import pdb; pdb.set_trace()
(Pdb) step
> <doctest test.test_doctest.test_doctest.test_pdb_set_trace_nested[0]>(5)calls_set_trace()
-> self.f1()
(Pdb) print(y)
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp