@@ -586,7 +586,7 @@ def _complete_expression(self, text, line, begidx, endidx):
586
586
# Return true to exit from the command loop
587
587
588
588
def do_commands (self , arg ):
589
- """commands [bpnumber]
589
+ """(Pdb) commands [bpnumber]
590
590
(com) ...
591
591
(com) end
592
592
(Pdb)
@@ -672,6 +672,7 @@ def do_commands(self, arg):
672
672
673
673
def do_break (self , arg , temporary = 0 ):
674
674
"""b(reak) [ ([filename:]lineno | function) [, condition] ]
675
+
675
676
Without argument, list all breaks.
676
677
677
678
With a line number argument, set a break at this line in the
@@ -780,6 +781,7 @@ def defaultFile(self):
780
781
781
782
def do_tbreak (self , arg ):
782
783
"""tbreak [ ([filename:]lineno | function) [, condition] ]
784
+
783
785
Same arguments as break, but sets a temporary breakpoint: it
784
786
is automatically deleted when first hit.
785
787
"""
@@ -844,6 +846,7 @@ def checkline(self, filename, lineno):
844
846
845
847
def do_enable (self , arg ):
846
848
"""enable bpnumber [bpnumber ...]
849
+
847
850
Enables the breakpoints given as a space separated list of
848
851
breakpoint numbers.
849
852
"""
@@ -861,6 +864,7 @@ def do_enable(self, arg):
861
864
862
865
def do_disable (self , arg ):
863
866
"""disable bpnumber [bpnumber ...]
867
+
864
868
Disables the breakpoints given as a space separated list of
865
869
breakpoint numbers. Disabling a breakpoint means it cannot
866
870
cause the program to stop execution, but unlike clearing a
@@ -881,6 +885,7 @@ def do_disable(self, arg):
881
885
882
886
def do_condition (self , arg ):
883
887
"""condition bpnumber [condition]
888
+
884
889
Set a new condition for the breakpoint, an expression which
885
890
must evaluate to true before the breakpoint is honored. If
886
891
condition is absent, any existing condition is removed; i.e.,
@@ -911,6 +916,7 @@ def do_condition(self, arg):
911
916
912
917
def do_ignore (self , arg ):
913
918
"""ignore bpnumber [count]
919
+
914
920
Set the ignore count for the given breakpoint number. If
915
921
count is omitted, the ignore count is set to 0. A breakpoint
916
922
becomes active when the ignore count is zero. When non-zero,
@@ -945,7 +951,8 @@ def do_ignore(self, arg):
945
951
complete_ignore = _complete_bpnumber
946
952
947
953
def do_clear (self , arg ):
948
- """cl(ear) filename:lineno\n cl(ear) [bpnumber [bpnumber...]]
954
+ """cl(ear) [filename:lineno | bpnumber ...]
955
+
949
956
With a space separated list of breakpoint numbers, clear
950
957
those breakpoints. Without argument, clear all breaks (but
951
958
first ask confirmation). With a filename:lineno argument,
@@ -997,6 +1004,7 @@ def do_clear(self, arg):
997
1004
998
1005
def do_where (self , arg ):
999
1006
"""w(here)
1007
+
1000
1008
Print a stack trace, with the most recent frame at the bottom.
1001
1009
An arrow indicates the "current frame", which determines the
1002
1010
context of most commands. 'bt' is an alias for this command.
@@ -1015,6 +1023,7 @@ def _select_frame(self, number):
1015
1023
1016
1024
def do_up (self , arg ):
1017
1025
"""u(p) [count]
1026
+
1018
1027
Move the current frame count (default one) levels up in the
1019
1028
stack trace (to an older frame).
1020
1029
"""
@@ -1035,6 +1044,7 @@ def do_up(self, arg):
1035
1044
1036
1045
def do_down (self , arg ):
1037
1046
"""d(own) [count]
1047
+
1038
1048
Move the current frame count (default one) levels down in the
1039
1049
stack trace (to a newer frame).
1040
1050
"""
@@ -1055,6 +1065,7 @@ def do_down(self, arg):
1055
1065
1056
1066
def do_until (self , arg ):
1057
1067
"""unt(il) [lineno]
1068
+
1058
1069
Without argument, continue execution until the line with a
1059
1070
number greater than the current one is reached. With a line
1060
1071
number, continue execution until a line with a number greater
@@ -1079,6 +1090,7 @@ def do_until(self, arg):
1079
1090
1080
1091
def do_step (self , arg ):
1081
1092
"""s(tep)
1093
+
1082
1094
Execute the current line, stop at the first possible occasion
1083
1095
(either in a function that is called or in the current
1084
1096
function).
@@ -1089,6 +1101,7 @@ def do_step(self, arg):
1089
1101
1090
1102
def do_next (self , arg ):
1091
1103
"""n(ext)
1104
+
1092
1105
Continue execution until the next line in the current function
1093
1106
is reached or it returns.
1094
1107
"""
@@ -1098,6 +1111,7 @@ def do_next(self, arg):
1098
1111
1099
1112
def do_run (self , arg ):
1100
1113
"""run [args...]
1114
+
1101
1115
Restart the debugged python program. If a string is supplied
1102
1116
it is split with "shlex", and the result is used as the new
1103
1117
sys.argv. History, breakpoints, actions and debugger options
@@ -1119,6 +1133,7 @@ def do_run(self, arg):
1119
1133
1120
1134
def do_return (self , arg ):
1121
1135
"""r(eturn)
1136
+
1122
1137
Continue execution until the current function returns.
1123
1138
"""
1124
1139
self .set_return (self .curframe )
@@ -1127,6 +1142,7 @@ def do_return(self, arg):
1127
1142
1128
1143
def do_continue (self , arg ):
1129
1144
"""c(ont(inue))
1145
+
1130
1146
Continue execution, only stop when a breakpoint is encountered.
1131
1147
"""
1132
1148
if not self .nosigint :
@@ -1145,6 +1161,7 @@ def do_continue(self, arg):
1145
1161
1146
1162
def do_jump (self , arg ):
1147
1163
"""j(ump) lineno
1164
+
1148
1165
Set the next line that will be executed. Only available in
1149
1166
the bottom-most frame. This lets you jump back and execute
1150
1167
code again, or jump forward to skip code that you don't want
@@ -1174,6 +1191,7 @@ def do_jump(self, arg):
1174
1191
1175
1192
def do_debug (self , arg ):
1176
1193
"""debug code
1194
+
1177
1195
Enter a recursive debugger that steps through the code
1178
1196
argument (which is an arbitrary expression or statement to be
1179
1197
executed in the current environment).
@@ -1195,7 +1213,8 @@ def do_debug(self, arg):
1195
1213
complete_debug = _complete_expression
1196
1214
1197
1215
def do_quit (self , arg ):
1198
- """q(uit)\n exit
1216
+ """q(uit) | exit
1217
+
1199
1218
Quit from the debugger. The program being executed is aborted.
1200
1219
"""
1201
1220
self ._user_requested_quit = True
@@ -1207,6 +1226,7 @@ def do_quit(self, arg):
1207
1226
1208
1227
def do_EOF (self , arg ):
1209
1228
"""EOF
1229
+
1210
1230
Handles the receipt of EOF as a command.
1211
1231
"""
1212
1232
self .message ('' )
@@ -1216,6 +1236,7 @@ def do_EOF(self, arg):
1216
1236
1217
1237
def do_args (self , arg ):
1218
1238
"""a(rgs)
1239
+
1219
1240
Print the argument list of the current function.
1220
1241
"""
1221
1242
co = self .curframe .f_code
@@ -1233,6 +1254,7 @@ def do_args(self, arg):
1233
1254
1234
1255
def do_retval (self , arg ):
1235
1256
"""retval
1257
+
1236
1258
Print the return value for the last return of a function.
1237
1259
"""
1238
1260
if '__return__' in self .curframe_locals :
@@ -1273,12 +1295,14 @@ def _msg_val_func(self, arg, func):
1273
1295
1274
1296
def do_p (self , arg ):
1275
1297
"""p expression
1298
+
1276
1299
Print the value of the expression.
1277
1300
"""
1278
1301
self ._msg_val_func (arg , repr )
1279
1302
1280
1303
def do_pp (self , arg ):
1281
1304
"""pp expression
1305
+
1282
1306
Pretty-print the value of the expression.
1283
1307
"""
1284
1308
self ._msg_val_func (arg , pprint .pformat )
@@ -1288,7 +1312,7 @@ def do_pp(self, arg):
1288
1312
complete_pp = _complete_expression
1289
1313
1290
1314
def do_list (self , arg ):
1291
- """l(ist) [first [, last] | .]
1315
+ """l(ist) [first[, last] | .]
1292
1316
1293
1317
List source code for the current file. Without arguments,
1294
1318
list 11 lines around the current line or continue the previous
@@ -1345,7 +1369,8 @@ def do_list(self, arg):
1345
1369
do_l = do_list
1346
1370
1347
1371
def do_longlist (self , arg ):
1348
- """longlist | ll
1372
+ """ll | longlist
1373
+
1349
1374
List the whole source code for the current function or frame.
1350
1375
"""
1351
1376
filename = self .curframe .f_code .co_filename
@@ -1360,6 +1385,7 @@ def do_longlist(self, arg):
1360
1385
1361
1386
def do_source (self , arg ):
1362
1387
"""source expression
1388
+
1363
1389
Try to get source code for the given object and display it.
1364
1390
"""
1365
1391
try :
@@ -1397,7 +1423,8 @@ def _print_lines(self, lines, start, breaks=(), frame=None):
1397
1423
self .message (s + '\t ' + line .rstrip ())
1398
1424
1399
1425
def do_whatis (self , arg ):
1400
- """whatis arg
1426
+ """whatis expression
1427
+
1401
1428
Print the type of the argument.
1402
1429
"""
1403
1430
try :
@@ -1485,7 +1512,8 @@ def do_interact(self, arg):
1485
1512
code .interact ("*interactive*" , local = ns )
1486
1513
1487
1514
def do_alias (self , arg ):
1488
- """alias [name [command [parameter parameter ...] ]]
1515
+ """alias [name [command]]
1516
+
1489
1517
Create an alias called 'name' that executes 'command'. The
1490
1518
command must *not* be enclosed in quotes. Replaceable
1491
1519
parameters can be indicated by %1, %2, and so on, while %* is
@@ -1521,6 +1549,7 @@ def do_alias(self, arg):
1521
1549
1522
1550
def do_unalias (self , arg ):
1523
1551
"""unalias name
1552
+
1524
1553
Delete the specified alias.
1525
1554
"""
1526
1555
args = arg .split ()
@@ -1563,6 +1592,7 @@ def print_stack_entry(self, frame_lineno, prompt_prefix=line_prefix):
1563
1592
1564
1593
def do_help (self , arg ):
1565
1594
"""h(elp)
1595
+
1566
1596
Without argument, print the list of available commands.
1567
1597
With a command name as argument, print help about that command.
1568
1598
"help pdb" shows the full pdb documentation.
@@ -1586,12 +1616,13 @@ def do_help(self, arg):
1586
1616
if command .__doc__ is None :
1587
1617
self .error ('No help for %r; __doc__ string missing' % arg )
1588
1618
return
1589
- self .message (command .__doc__ . rstrip ( ))
1619
+ self .message (self . _help_message_from_doc ( command .__doc__ ))
1590
1620
1591
1621
do_h = do_help
1592
1622
1593
1623
def help_exec (self ):
1594
1624
"""(!) statement
1625
+
1595
1626
Execute the (one-line) statement in the context of the current
1596
1627
stack frame. The exclamation point can be omitted unless the
1597
1628
first word of the statement resembles a debugger command. To
@@ -1672,6 +1703,26 @@ def _getsourcelines(self, obj):
1672
1703
lineno = max (1 , lineno )
1673
1704
return lines , lineno
1674
1705
1706
+ def _help_message_from_doc (self , doc ):
1707
+ lines = [line .strip () for line in doc .rstrip ().splitlines ()]
1708
+ if not lines :
1709
+ return "No help message found."
1710
+ if "" in lines :
1711
+ usage_end = lines .index ("" )
1712
+ else :
1713
+ usage_end = 1
1714
+ formatted = []
1715
+ indent = " " * len (self .prompt )
1716
+ for i , line in enumerate (lines ):
1717
+ if i == 0 :
1718
+ prefix = "Usage: "
1719
+ elif i < usage_end :
1720
+ prefix = " "
1721
+ else :
1722
+ prefix = ""
1723
+ formatted .append (indent + prefix + line )
1724
+ return "\n " .join (formatted )
1725
+
1675
1726
# Collect all command help into docstring, if not run with -OO
1676
1727
1677
1728
if __doc__ is not None :
0 commit comments