Zsolt Haraszti <[EMAIL PROTECTED]> added the comment:

We are also using inspect.getsourceline() in a large system at my
company and we observed some unreliable behavior in the past which we
never had time to analyze till today. Interesting coincidence, but today
we finally took the effort and traced the issue, and we found that:

getsourceline() does not report the last line of a class definition body
_IF_:
  (1) that line is the last line of the file, _AND_
  (2) that line is not terminated with a newline (\n)

This also answers Alexandre's question: yes, the problem happens only if
the line is unterminated.

I understand that an unterminated line may be non-conforming per Python
specs, but my WingIDE happily saved the file, so I suspect other editors
may just do the same, and I do agree with Rafe that it would be nice if
inspect would be resilient against the missing \n. I assume there would
be no harm, and it could eliminate some angst (it is really not obvious
first why it fails).

I would really love to see this fixed in a patch release on the 2.5+
lines. Any chance?

----------
nosy: +zsolt

_______________________________________
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue4335>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to