[ python-Bugs-832535 ] Inconsitent line numbering in traceback

SourceForge.net noreply at sourceforge.net
Thu Jan 1 23:18:22 EST 2004


Bugs item #832535, was opened at 2003-10-29 12:48
Message generated for change (Comment added) made by kbk
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=832535&group_id=5470

Category: IDLE
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Kirby Urner (urnerk)
>Assigned to: Kurt B. Kaiser (kbk)
Summary: Inconsitent line numbering in traceback

Initial Comment:
Transcript below documents the problem.  

A traceback shows a line with no float() op, but 
complains of a float op error.  

I restart the shell, with no changes to the imported 
module, and this time line 45 is correctly listed.

>>> reload(brawley)
<module 'brawley' from 'C:\Documents and 
Settings\Kirby\My 
Documents\FreeGeek\PythonicGeom\brawley.py'>
>>> brawley.test2()
elems: 3, 4, 5, 0.5, 'White', 
sublist: 7,8,9]

['3', ' 4', ' 5', ' 0.5', " 'White'", ' ']
['3', ' 4', ' 5', ' 0.5', " 'White'"]

Traceback (most recent call last):
  File "<pyshell#28>", line 1, in -toplevel-
    brawley.test2()
  File "C:\Documents and Settings\Kirby\My 
Documents\FreeGeek\PythonicGeom\brawley.py", line 
45, in test2
    color = elems[-2]
ValueError: invalid literal for float(): 'White
>>> ================================ 
RESTART ================================
>>> import brawley
>>> brawley.test2()
elems: 3, 4, 5, 0.5, 'White', 
sublist: 7,8,9]

['3', ' 4', ' 5', ' 0.5', " 'White'", ' ']
['3', ' 4', ' 5', ' 0.5', " 'White'"]

Traceback (most recent call last):
  File "<pyshell#30>", line 1, in -toplevel-
    brawley.test2()
  File "C:\Documents and Settings\Kirby\My 
Documents\FreeGeek\PythonicGeom\brawley.py", line 
45, in test2
    x,y,z,radius = [float(i) for i in elems[:-3].split(',')]
ValueError: invalid literal for float(): 'White


----------------------------------------------------------------------

>Comment By: Kurt B. Kaiser (kbk)
Date: 2004-01-01 23:18

Message:
Logged In: YES 
user_id=149084

The best way to use the new IDLE is to edit your file and 
then run it with F5.  Using reload() has always been
problematic and one of the reasons for going to the
subprocess was to eliminate those troubles.

However, I just checked in a patch due to Noam Raphael
which I believe will fix your problem.
IDLEfork Patch 869012.  Updated IDLEfork and
Python IDLE MAIN.  Let me know if it doesn't and
we'll reopen this.

----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2003-11-03 06:59

Message:
Logged In: YES 
user_id=6656

If by reload you mean the builtin function reload(), the
answer is probably because that would be a bitch to arrange
(have you ever looked at the import code?  scares me more
than most other in Python).  Could be done, though, and is
perhaps the right answer.  Other answers would be having
traceback.py not use linecache or deprecating and doing away
with linecache entirely.

----------------------------------------------------------------------

Comment By: Jeremy Fincher (jemfinch)
Date: 2003-10-31 14:41

Message:
Logged In: YES 
user_id=99508

Yeah, this is definitely the linecache problem.  Is there a
good reason why reload doesn't do a linecache.checkcache
itself?  I really doubt reload is being called inside
performance-sensitive code.

----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2003-10-29 13:02

Message:
Logged In: YES 
user_id=6656

Is this the hoary old "being lied to by linecache" thing?  I
complain about that every now and again, but haven't
actually done anything about it yet...

----------------------------------------------------------------------

Comment By: Kirby Urner (urnerk)
Date: 2003-10-29 12:56

Message:
Logged In: YES 
user_id=191709

It's a little more serious.  After a save/reload, the traceback 
will echo code that's no longer present in the source at all.

Traceback (most recent call last):
  File "<pyshell#34>", line 1, in -toplevel-
    brawley.test2()
  File "C:\Documents and Settings\Kirby\My 
Documents\FreeGeek\PythonicGeom\brawley.py", line 45, in 
test2
    x,y,z,radius = [float(i) for i in elems[:-3].split(',')]
ValueError: invalid literal for float(): 'White'

But line 45 in the saved/reloaded source is really:
        x,y,z,radius = [float(i) for i in elems.split(',')[:-1]]

When I restart the shell and import, the real source code is 
echoed.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=832535&group_id=5470



More information about the Python-bugs-list mailing list