Python Error Messages

François Pinard pinard at iro.umontreal.ca
Tue Sep 14 22:37:50 EDT 1999


"Tim Peters" <tim_one at email.msn.com> writes:

> [jonathon]
> > Why are PythonError messages so annoying?

> Because the tracebacks you're getting aren't showing the lines of code
> that are actually failing.  I can explain why that's happening, but it's
> obscure: when Python goes to print a traceback, it uses the platform libc
> fgets function to read one line at a time, until the target line number
> is reached.  It passes fgets a buffer big enough to hold 1000 characters.
> fgets won't actually read a full line if it sees 1000 characters go by
> without seeing a newline, so any line of code in your .py file that's
> longer than 1000 characters will screw up the line count hopelessly.

Seriously, couldn't we consider this as an implementation bug?  If fgets
did not return a whole line, the line count should not get incremented.

Of course, we might start arguing whether long lines are poor style or not,
but this is a rather different point.  In fact, for stylistic issues, I
guess we would easily agree.  The point here is that the implementation
should definitely do the proper thing regardless of the line length,
and style considerations are no excuse for not counting lines correctly.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard





More information about the Python-list mailing list