Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f4aac48

Browse files
committed
minor update
1 parent 0bf4d89 commit f4aac48

2 files changed

Lines changed: 90 additions & 80 deletions

File tree

Doc/lib/libpdb.tex

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
1-
\section{Standard module \sectcode{pdb}}
1+
\chapter{The Python Debugger}
22
\stmodindex{pdb}
33
\index{debugging}
44

5-
This module defines an interactive source code debugger for Python
6-
programs. It supports breakpoints and single stepping at the source
7-
line level, inspection of stack frames, source code listing, and
8-
evaluation of arbitrary Python code in the context of any stack frame.
9-
It also supports post-mortem debugging and can be called under program
10-
control.
5+
\renewcommand{\indexsubitem}{(in module pdb)}
6+
7+
The module \code{pdb} defines an interactive source code debugger for
8+
Python programs. It supports setting breakpoints and single stepping
9+
at the source line level, inspection of stack frames, source code
10+
listing, and evaluation of arbitrary Python code in the context of any
11+
stack frame. It also supports post-mortem debugging and can be called
12+
under program control.
1113

1214
The debugger is extensible --- it is actually defined as a class
1315
\code{Pdb}. The extension interface uses the (also undocumented)
14-
modules \code{bdb} and \code{cmd}; it is currently undocumented.
16+
modules \code{bdb} and \code{cmd}; it is currently undocumented but
17+
easily understood by reading the source.
1518
\ttindex{Pdb}
1619
\ttindex{bdb}
1720
\ttindex{cmd}
1821

1922
A primitive windowing version of the debugger also exists --- this is
20-
module \code{wdb}, which requires STDWIN.
23+
module \code{wdb}, which requires STDWIN (see the chapter on STDWIN
24+
specific modules).
2125
\index{stdwin}
2226
\ttindex{wdb}
2327

@@ -47,42 +51,43 @@ \section{Standard module \sectcode{pdb}}
4751
in a slightly different way:
4852

4953
\begin{funcdesc}{run}{statement\optional{\, globals\optional{\, locals}}}
50-
Execute the \var{statement} (which should be a string) under debugger
54+
Execute the \var{statement} (given as a string) under debugger
5155
control. The debugger prompt appears before any code is executed; you
52-
can set breakpoint and type \code{continue}, or you can step through
53-
the statement using \code{step} or \code{next}. The optional
54-
\var{globals} and \var{locals} arguments specify the environment in
55-
which the code is executed; by default the dictionary of the module
56-
\code{__main__} is used. (See the explanation of the \code{exec}
57-
statement or the \code{eval()} built-in function.)
56+
can set breakpoints and type \code{continue}, or you can step through
57+
the statement using \code{step} or \code{next} (all these commands are
58+
explained below). The optional \var{globals} and \var{locals}
59+
arguments specify the environment in which the code is executed; by
60+
default the dictionary of the module \code{__main__} is used. (See
61+
the explanation of the \code{exec} statement or the \code{eval()}
62+
built-in function.)
5863
\end{funcdesc}
5964

6065
\begin{funcdesc}{runeval}{expression\optional{\, globals\optional{\, locals}}}
61-
Evaluate the \var{expression} (which should be a string) under
62-
debugger control. When \code{runeval()} returns, it returns the value
63-
of the expression. Otherwise this function is similar to
66+
Evaluate the \var{expression} (given as a a string) under debugger
67+
control. When \code{runeval()} returns, it returns the value of the
68+
expression. Otherwise this function is similar to
6469
\code{run()}.
6570
\end{funcdesc}
6671

6772
\begin{funcdesc}{runcall}{function\optional{\, argument\, ...}}
68-
Call the \var{function} (which should be a callable Python object, not
69-
a string) with the given arguments. When \code{runcall()} returns, it
70-
returns the return value of the function call. The debugger prompt
71-
appears as soon as the function is entered.
73+
Call the \var{function} (a function or method object, not a string)
74+
with the given arguments. When \code{runcall()} returns, it returns
75+
whatever the function call returned. The debugger prompt appears as
76+
soon as the function is entered.
7277
\end{funcdesc}
7378

7479
\begin{funcdesc}{set_trace}{}
7580
Enter the debugger at the calling stack frame. This is useful to
76-
hard-code a breakpoint at a given point in code, even if the code is
77-
not otherwise being debugged.
81+
hard-code a breakpoint at a given point in a program, even if the code
82+
is not otherwise being debugged (e.g. when an assertion fails).
7883
\end{funcdesc}
7984

8085
\begin{funcdesc}{post_mortem}{traceback}
8186
Enter post-mortem debugging of the given \var{traceback} object.
8287
\end{funcdesc}
8388

8489
\begin{funcdesc}{pm}{}
85-
Enter post-mortem debugging based on the traceback found in
90+
Enter post-mortem debugging of the traceback found in
8691
\code{sys.last_traceback}.
8792
\end{funcdesc}
8893

@@ -118,9 +123,9 @@ \subsection{Debugger Commands}
118123
With a \var{command} as argument, print help about that command.
119124
``\code{help pdb}'' displays the full documentation file; if the
120125
environment variable \code{PAGER} is defined, the file is piped
121-
through that command instead. Since the var{command} argument must be
122-
an identifier, ``\code{help exec}'' gives help on the ``\code{!}''
123-
command.
126+
through that command instead. Since the \var{command} argument must be
127+
an identifier, ``\code{help exec}'' must be entered to get help on the
128+
``\code{!}'' command.
124129
125130
\item[{w(here)}]
126131
@@ -138,13 +143,13 @@ \subsection{Debugger Commands}
138143
Move the current frame one level up in the stack trace
139144
(to a newer frame).
140145
141-
\item[{b(reak) [\var{lineno} \code{|} \var{function}]}]
146+
\item[{b(reak) [\var{lineno}\code{|}\var{function}]}]
142147
143148
With a \var{lineno} argument, set a break there in the current
144149
file. With a \var{function} argument, set a break at the entry of
145150
that function. Without argument, list all breaks.
146151
147-
\item[{cl(ear) [lineno]}]
152+
\item[{cl(ear) [\var{lineno}]}]
148153
149154
With a \var{lineno} argument, clear that break in the current file.
150155
Without argument, clear all breaks (but first ask confirmation).
@@ -160,8 +165,8 @@ \subsection{Debugger Commands}
160165
Continue execution until the next line in the current function
161166
is reached or it returns. (The difference between \code{next} and
162167
\code{step} is that \code{step} stops inside a called function, while
163-
\code{next} executes called functions at full speed, only stopping at
164-
the next line in the current function.)
168+
\code{next} executes called functions at (nearly) full speed, only
169+
stopping at the next line in the current function.)
165170
166171
\item[{r(eturn)}]
167172
@@ -173,12 +178,11 @@ \subsection{Debugger Commands}
173178
174179
\item[{l(ist) [\var{first} [, \var{last}]]}]
175180
176-
List source code for the current file.
177-
Without arguments, list 11 lines around the current line
178-
or continue the previous listing.
179-
With one argument, list 11 lines around at that line.
180-
With two arguments, list the given range;
181-
if the second argument is less than the first, it is a count.
181+
List source code for the current file. Without arguments, list 11
182+
lines around the current line or continue the previous listing. With
183+
one argument, list 11 lines around at that line. With two arguments,
184+
list the given range; if the second argument is less than the first,
185+
it is interpreted as a count.
182186
183187
\item[{a(rgs)}]
184188
@@ -187,7 +191,8 @@ \subsection{Debugger Commands}
187191
\item[{p \var{expression}}]
188192
189193
Evaluate the \var{expression} in the current context and print its
190-
value.
194+
value. (Note: \code{print} can also be used, but is not a debugger
195+
command --- this executes the Python \code{print} statement.)
191196
192197
\item[{[!] \var{statement}}]
193198

Doc/libpdb.tex

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
1-
\section{Standard module \sectcode{pdb}}
1+
\chapter{The Python Debugger}
22
\stmodindex{pdb}
33
\index{debugging}
44

5-
This module defines an interactive source code debugger for Python
6-
programs. It supports breakpoints and single stepping at the source
7-
line level, inspection of stack frames, source code listing, and
8-
evaluation of arbitrary Python code in the context of any stack frame.
9-
It also supports post-mortem debugging and can be called under program
10-
control.
5+
\renewcommand{\indexsubitem}{(in module pdb)}
6+
7+
The module \code{pdb} defines an interactive source code debugger for
8+
Python programs. It supports setting breakpoints and single stepping
9+
at the source line level, inspection of stack frames, source code
10+
listing, and evaluation of arbitrary Python code in the context of any
11+
stack frame. It also supports post-mortem debugging and can be called
12+
under program control.
1113

1214
The debugger is extensible --- it is actually defined as a class
1315
\code{Pdb}. The extension interface uses the (also undocumented)
14-
modules \code{bdb} and \code{cmd}; it is currently undocumented.
16+
modules \code{bdb} and \code{cmd}; it is currently undocumented but
17+
easily understood by reading the source.
1518
\ttindex{Pdb}
1619
\ttindex{bdb}
1720
\ttindex{cmd}
1821

1922
A primitive windowing version of the debugger also exists --- this is
20-
module \code{wdb}, which requires STDWIN.
23+
module \code{wdb}, which requires STDWIN (see the chapter on STDWIN
24+
specific modules).
2125
\index{stdwin}
2226
\ttindex{wdb}
2327

@@ -47,42 +51,43 @@ \section{Standard module \sectcode{pdb}}
4751
in a slightly different way:
4852

4953
\begin{funcdesc}{run}{statement\optional{\, globals\optional{\, locals}}}
50-
Execute the \var{statement} (which should be a string) under debugger
54+
Execute the \var{statement} (given as a string) under debugger
5155
control. The debugger prompt appears before any code is executed; you
52-
can set breakpoint and type \code{continue}, or you can step through
53-
the statement using \code{step} or \code{next}. The optional
54-
\var{globals} and \var{locals} arguments specify the environment in
55-
which the code is executed; by default the dictionary of the module
56-
\code{__main__} is used. (See the explanation of the \code{exec}
57-
statement or the \code{eval()} built-in function.)
56+
can set breakpoints and type \code{continue}, or you can step through
57+
the statement using \code{step} or \code{next} (all these commands are
58+
explained below). The optional \var{globals} and \var{locals}
59+
arguments specify the environment in which the code is executed; by
60+
default the dictionary of the module \code{__main__} is used. (See
61+
the explanation of the \code{exec} statement or the \code{eval()}
62+
built-in function.)
5863
\end{funcdesc}
5964

6065
\begin{funcdesc}{runeval}{expression\optional{\, globals\optional{\, locals}}}
61-
Evaluate the \var{expression} (which should be a string) under
62-
debugger control. When \code{runeval()} returns, it returns the value
63-
of the expression. Otherwise this function is similar to
66+
Evaluate the \var{expression} (given as a a string) under debugger
67+
control. When \code{runeval()} returns, it returns the value of the
68+
expression. Otherwise this function is similar to
6469
\code{run()}.
6570
\end{funcdesc}
6671

6772
\begin{funcdesc}{runcall}{function\optional{\, argument\, ...}}
68-
Call the \var{function} (which should be a callable Python object, not
69-
a string) with the given arguments. When \code{runcall()} returns, it
70-
returns the return value of the function call. The debugger prompt
71-
appears as soon as the function is entered.
73+
Call the \var{function} (a function or method object, not a string)
74+
with the given arguments. When \code{runcall()} returns, it returns
75+
whatever the function call returned. The debugger prompt appears as
76+
soon as the function is entered.
7277
\end{funcdesc}
7378

7479
\begin{funcdesc}{set_trace}{}
7580
Enter the debugger at the calling stack frame. This is useful to
76-
hard-code a breakpoint at a given point in code, even if the code is
77-
not otherwise being debugged.
81+
hard-code a breakpoint at a given point in a program, even if the code
82+
is not otherwise being debugged (e.g. when an assertion fails).
7883
\end{funcdesc}
7984

8085
\begin{funcdesc}{post_mortem}{traceback}
8186
Enter post-mortem debugging of the given \var{traceback} object.
8287
\end{funcdesc}
8388

8489
\begin{funcdesc}{pm}{}
85-
Enter post-mortem debugging based on the traceback found in
90+
Enter post-mortem debugging of the traceback found in
8691
\code{sys.last_traceback}.
8792
\end{funcdesc}
8893

@@ -118,9 +123,9 @@ \subsection{Debugger Commands}
118123
With a \var{command} as argument, print help about that command.
119124
``\code{help pdb}'' displays the full documentation file; if the
120125
environment variable \code{PAGER} is defined, the file is piped
121-
through that command instead. Since the var{command} argument must be
122-
an identifier, ``\code{help exec}'' gives help on the ``\code{!}''
123-
command.
126+
through that command instead. Since the \var{command} argument must be
127+
an identifier, ``\code{help exec}'' must be entered to get help on the
128+
``\code{!}'' command.
124129
125130
\item[{w(here)}]
126131
@@ -138,13 +143,13 @@ \subsection{Debugger Commands}
138143
Move the current frame one level up in the stack trace
139144
(to a newer frame).
140145
141-
\item[{b(reak) [\var{lineno} \code{|} \var{function}]}]
146+
\item[{b(reak) [\var{lineno}\code{|}\var{function}]}]
142147
143148
With a \var{lineno} argument, set a break there in the current
144149
file. With a \var{function} argument, set a break at the entry of
145150
that function. Without argument, list all breaks.
146151
147-
\item[{cl(ear) [lineno]}]
152+
\item[{cl(ear) [\var{lineno}]}]
148153
149154
With a \var{lineno} argument, clear that break in the current file.
150155
Without argument, clear all breaks (but first ask confirmation).
@@ -160,8 +165,8 @@ \subsection{Debugger Commands}
160165
Continue execution until the next line in the current function
161166
is reached or it returns. (The difference between \code{next} and
162167
\code{step} is that \code{step} stops inside a called function, while
163-
\code{next} executes called functions at full speed, only stopping at
164-
the next line in the current function.)
168+
\code{next} executes called functions at (nearly) full speed, only
169+
stopping at the next line in the current function.)
165170
166171
\item[{r(eturn)}]
167172
@@ -173,12 +178,11 @@ \subsection{Debugger Commands}
173178
174179
\item[{l(ist) [\var{first} [, \var{last}]]}]
175180
176-
List source code for the current file.
177-
Without arguments, list 11 lines around the current line
178-
or continue the previous listing.
179-
With one argument, list 11 lines around at that line.
180-
With two arguments, list the given range;
181-
if the second argument is less than the first, it is a count.
181+
List source code for the current file. Without arguments, list 11
182+
lines around the current line or continue the previous listing. With
183+
one argument, list 11 lines around at that line. With two arguments,
184+
list the given range; if the second argument is less than the first,
185+
it is interpreted as a count.
182186
183187
\item[{a(rgs)}]
184188
@@ -187,7 +191,8 @@ \subsection{Debugger Commands}
187191
\item[{p \var{expression}}]
188192
189193
Evaluate the \var{expression} in the current context and print its
190-
value.
194+
value. (Note: \code{print} can also be used, but is not a debugger
195+
command --- this executes the Python \code{print} statement.)
191196
192197
\item[{[!] \var{statement}}]
193198

0 commit comments

Comments
 (0)