Issue 832535: Inconsitent line numbering in traceback (original) (raw)
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
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.