[Python-bugs-list] [ python-Bugs-431772 ] traceback.print_exc() causes traceback
noreply@sourceforge.net
noreply@sourceforge.net
Sun, 10 Jun 2001 11:58:49 -0700
Bugs item #431772, was updated on 2001-06-10 00:55
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=431772&group_id=5470
>Category: Python Library
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Atsuo Ishimoto (atsuoi)
>Assigned to: Tim Peters (tim_one)
Summary: traceback.print_exc() causes traceback
Initial Comment:
Executing this code:
import traceback
try:
comp = compile('def aaa
(a=1,b):pass', '<interactive input>','exec')
except:
traceback.print_exc()
causes exception with Python 2.1/Win32.
Traceback (most recent call last):
File "a.py", line 3, in ?
comp = compile('def aaa
(a=1,b):pass', '<interactive input>','exec')
Traceback (most recent call last):
File "a.py", line 5, in ?
traceback.print_exc()
File "c:\tools\python21\lib\traceback.py", line 209,
in print_exc
print_exception(etype, value, tb, limit, file)
File "c:\tools\python21\lib\traceback.py", line 124,
in print_exception
lines = format_exception_only(etype, value)
File "c:\tools\python21\lib\traceback.py", line 175,
in format_exception_only
while i < len(line) and line[i].isspace():
TypeError: len() of unsized object
----------------------------------------------------------------------
>Comment By: Tim Peters (tim_one)
Date: 2001-06-10 11:58
Message:
Logged In: YES
user_id=31435
Thank you, Michael! I checked this in,
Lib/traceback.py, rev 1.26.
----------------------------------------------------------------------
Comment By: Michael Hudson (mwh)
Date: 2001-06-10 04:50
Message:
Logged In: YES
user_id=6656
I think this patch:
Index: traceback.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/traceback.py,v
retrieving revision 1.25
diff -c -r1.25 traceback.py
*** traceback.py 2001/03/29 04:36:08 1.25
--- traceback.py 2001/06/10 11:48:51
***************
*** 171,189 ****
if not filename: filename = "<string>"
list.append(' File "%s", line %d\n' %
(filename, lineno))
! i = 0
! while i < len(line) and line[i].isspace():
! i = i+1
! list.append(' %s\n' % line.strip())
! if offset is not None:
! s = ' '
! for c in line[i:offset-1]:
! if c.isspace():
! s = s + c
! else:
! s = s + ' '
! list.append('%s^\n' % s)
! value = msg
s = _some_str(value)
if s:
list.append('%s: %s\n' % (str(stype), s))
--- 171,190 ----
if not filename: filename = "<string>"
list.append(' File "%s", line %d\n' %
(filename, lineno))
! if line is not None:
! i = 0
! while i < len(line) and line[i].isspace():
! i = i+1
! list.append(' %s\n' % line.strip())
! if offset is not None:
! s = ' '
! for c in line[i:offset-1]:
! if c.isspace():
! s = s + c
! else:
! s = s + ' '
! list.append('%s^\n' % s)
! value = msg
s = _some_str(value)
if s:
list.append('%s: %s\n' % (str(stype), s))
fixes this.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=431772&group_id=5470