@@ -1286,6 +1286,9 @@ def do_enable(self, arg):
1286
1286
Enables the breakpoints given as a space separated list of
1287
1287
breakpoint numbers.
1288
1288
"""
1289
+ if not arg :
1290
+ self ._print_invalid_arg (arg )
1291
+ return
1289
1292
args = arg .split ()
1290
1293
for i in args :
1291
1294
try :
@@ -1307,6 +1310,9 @@ def do_disable(self, arg):
1307
1310
breakpoint, it remains in the list of breakpoints and can be
1308
1311
(re-)enabled.
1309
1312
"""
1313
+ if not arg :
1314
+ self ._print_invalid_arg (arg )
1315
+ return
1310
1316
args = arg .split ()
1311
1317
for i in args :
1312
1318
try :
@@ -1327,6 +1333,9 @@ def do_condition(self, arg):
1327
1333
condition is absent, any existing condition is removed; i.e.,
1328
1334
the breakpoint is made unconditional.
1329
1335
"""
1336
+ if not arg :
1337
+ self ._print_invalid_arg (arg )
1338
+ return
1330
1339
args = arg .split (' ' , 1 )
1331
1340
try :
1332
1341
cond = args [1 ]
@@ -1360,6 +1369,9 @@ def do_ignore(self, arg):
1360
1369
and the breakpoint is not disabled and any associated
1361
1370
condition evaluates to true.
1362
1371
"""
1372
+ if not arg :
1373
+ self ._print_invalid_arg (arg )
1374
+ return
1363
1375
args = arg .split ()
1364
1376
if not args :
1365
1377
self .error ('Breakpoint number expected' )
@@ -1690,6 +1702,9 @@ def do_jump(self, arg):
1690
1702
instance it is not possible to jump into the middle of a
1691
1703
for loop or out of a finally clause.
1692
1704
"""
1705
+ if not arg :
1706
+ self ._print_invalid_arg (arg )
1707
+ return
1693
1708
if self .curindex + 1 != len (self .stack ):
1694
1709
self .error ('You can only jump within the bottom frame' )
1695
1710
return
@@ -1715,6 +1730,9 @@ def do_debug(self, arg):
1715
1730
argument (which is an arbitrary expression or statement to be
1716
1731
executed in the current environment).
1717
1732
"""
1733
+ if not arg :
1734
+ self ._print_invalid_arg (arg )
1735
+ return
1718
1736
sys .settrace (None )
1719
1737
globals = self .curframe .f_globals
1720
1738
locals = self .curframe .f_locals
@@ -1840,13 +1858,19 @@ def do_p(self, arg):
1840
1858
1841
1859
Print the value of the expression.
1842
1860
"""
1861
+ if not arg :
1862
+ self ._print_invalid_arg (arg )
1863
+ return
1843
1864
self ._msg_val_func (arg , repr )
1844
1865
1845
1866
def do_pp (self , arg ):
1846
1867
"""pp expression
1847
1868
1848
1869
Pretty-print the value of the expression.
1849
1870
"""
1871
+ if not arg :
1872
+ self ._print_invalid_arg (arg )
1873
+ return
1850
1874
self ._msg_val_func (arg , pprint .pformat )
1851
1875
1852
1876
complete_print = _complete_expression
@@ -1935,6 +1959,9 @@ def do_source(self, arg):
1935
1959
1936
1960
Try to get source code for the given object and display it.
1937
1961
"""
1962
+ if not arg :
1963
+ self ._print_invalid_arg (arg )
1964
+ return
1938
1965
try :
1939
1966
obj = self ._getval (arg )
1940
1967
except :
@@ -1974,6 +2001,9 @@ def do_whatis(self, arg):
1974
2001
1975
2002
Print the type of the argument.
1976
2003
"""
2004
+ if not arg :
2005
+ self ._print_invalid_arg (arg )
2006
+ return
1977
2007
try :
1978
2008
value = self ._getval (arg )
1979
2009
except :
@@ -2318,7 +2348,10 @@ def _help_message_from_doc(self, doc, usage_only=False):
2318
2348
def _print_invalid_arg (self , arg ):
2319
2349
"""Return the usage string for a function."""
2320
2350
2321
- self .error (f"Invalid argument: { arg } " )
2351
+ if not arg :
2352
+ self .error ("Argument is required for this command" )
2353
+ else :
2354
+ self .error (f"Invalid argument: { arg } " )
2322
2355
2323
2356
# Yes it's a bit hacky. Get the caller name, get the method based on
2324
2357
# that name, and get the docstring from that method.
0 commit comments