[Python-bugs-list] [ python-Bugs-579701 ] pdb crashes with spaces in input

noreply@sourceforge.net noreply@sourceforge.net
Thu, 11 Jul 2002 20:10:33 -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: Open
Resolution: None
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: 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