[Tutor] Capturing assert source code line
Thu, 8 Jun 2000 12:10:07 +0200
On Thu, Jun 08, 2000 at 11:52:07AM +0200, Remco Gerlich wrote:
> So you can reconstruct it with the code object (its co_filename variable)
> and the lineno from the frame.
> This is also the reason why the interpreter only shows the first line if
> your expression spans multiple lines... very annoying.
Actually, I was looking at the source because of this (Lib/traceback.py),
and it finds the line from the file by using the linecache module.
print linecache.getline(filename, lineno)
This module looks in the module path, and checks if files have changed since
last accessed. Oddly enough, I can't get it to show the changed file until I
actually let it show an exception, so I haven't found out everything yet.
But showing the file as it was when the module was compiled is what you want
Remco Gerlich, email@example.com