This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Inconsitent line numbering in traceback
Type: Stage:
Components: IDLE Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: kbk Nosy List: jemfinch, kbk, mwh, urnerk
Priority: normal Keywords:

Created on 2003-10-29 17:48 by urnerk, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg18804 - (view) Author: Kirby Urner (urnerk) Date: 2003-10-29 17:48
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
msg18805 - (view) Author: Kirby Urner (urnerk) Date: 2003-10-29 17:56
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.
msg18806 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2003-10-29 18:02
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...
msg18807 - (view) Author: Jeremy Fincher (jemfinch) Date: 2003-10-31 19:41
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.
msg18808 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2003-11-03 11:59
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.
msg18809 - (view) Author: Kurt B. Kaiser (kbk) * (Python committer) Date: 2004-01-02 04:18
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.
History
Date User Action Args
2022-04-11 14:56:00adminsetgithub: 39474
2003-10-29 17:48:16urnerkcreate