[Python-bugs-list] [ python-Bugs-579701 ] pdb crashes with spaces in input
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 12 Jul 2002 06:14:14 -0700
Bugs item #579701, was opened at 2002-07-10 12:36
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=579701&group_id=5470
Category: Python Library
Group: Python 2.2
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Fernando Pérez (fer_perez)
>Assigned to: Guido van Rossum (gvanrossum)
Summary: pdb crashes with spaces in input
Initial Comment:
In a pdb session, if the input line consists _only_ of
whitespace, pdb crashes. Here's an example with
traceback:
Python 2.2 (#1, Feb 15 2002, 16:48:24)
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)] on
linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> import pdb
>>> 1/0
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ZeroDivisionError: integer division or modulo by zero
>>> pdb.pm()
> <stdin>(1)?()
(Pdb) # <<<< a few blank spaces were typed here
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/users/fperez/local/lib/python/pdb.py", line
908, in pm
post_mortem(sys.last_traceback)
File "/usr/users/fperez/local/lib/python/pdb.py", line
905, in post_mortem
p.interaction(t.tb_frame, t)
File "/usr/users/fperez/local/lib/python/pdb.py", line
135, in interaction
self.cmdloop()
File "/usr/users/fperez/local/lib/python2.2/cmd.py",
line 102, in cmdloop
line = self.precmd(line)
File "/usr/users/fperez/local/lib/python/pdb.py", line
158, in precmd
while self.aliases.has_key(args[0]):
IndexError: list index out of range
>>>
The fix is very simple (no patch attached, it's just a
one-liner): line 154 of pdb.py reads:
if not line:
it should become:
if not line.strip():
This guarantees that later no access by index is
attempted on an empty list.
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-07-12 09:14
Message:
Logged In: YES
user_id=6380
Too bad, I already checked in the original fix. :-)
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2002-07-12 00:12
Message:
Logged In: YES
user_id=31435
Assigned back to you, Neal, and marked Accepted. The
idea is right, but is more naturally done by removing the "if
not line:" block and adding
if not args:
return line
right before the while loop instead.
----------------------------------------------------------------------
Comment By: Neal Norwitz (nnorwitz)
Date: 2002-07-11 23:10
Message:
Logged In: YES
user_id=33168
The suggested fix works for me.
Guido, if this seems right, assign to me and
I'll check in the change.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=579701&group_id=5470