[Idle-dev] [ idlefork-Patches-869012 ] Update linecache when
showing exceptions
SourceForge.net
noreply at sourceforge.net
Thu Jan 1 18:58:06 EST 2004
Patches item #869012, was opened at 2004-01-02 01:58
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=309579&aid=869012&group_id=9579
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Noam Raphael (noamr)
Assigned to: Nobody/Anonymous (nobody)
Summary: Update linecache when showing exceptions
Initial Comment:
When exceptions are shown, the linecache module is
being used. If a file was changed while IDLE was
running, linecache won't know about it and will show
the line from the file in cache, which is very
confusing sometimes, since it may have no relation to
what actually caused the exception.
An example:
>>> file("t.py", "w").write("1/0")
>>> execfile("t.py")
Traceback (most recent call last):
File "<pyshell#17>", line 1, in -toplevel-
execfile("t.py")
File "t.py", line 1, in -toplevel-
1/0
ZeroDivisionError: integer division or modulo by zero
>>> file("t.py", "w").write("2/0")
>>> execfile("t.py")
Traceback (most recent call last):
File "<pyshell#19>", line 1, in -toplevel-
execfile("t.py")
File "t.py", line 1, in -toplevel-
1/0 <======== Should have been 2/0!
ZeroDivisionError: integer division or modulo by zero
The solution is to add those two line at the beginning
of function print_exception in run.py (after line 113):
def print_exception():
+ import linecache
+ linecache.checkcache()
This causes the cache to update itself, and the correct
line is shown.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=309579&aid=869012&group_id=9579
More information about the IDLE-dev
mailing list