Author brett.cannon
Recipients brett.cannon, christian.heimes, nnorwitz
Date 2007-11-30.07:57:05
SpamBayes Score 0.0106608
Marked as misclassified No
Message-id <1196409427.0.0.769312490478.issue1631171@psf.upfronthosting.co.za>
In-reply-to
Content
I see two ways of implementing the fetching of a source code line from
__loader__.get_source().

One is to do it in Python.  We have a function provided that can
suppress the second line of output from a warning and just handle it in
Python code.  That has the requirement that Python code be available to
import, but if you are using Lib/warnings.py instead of
Python/_warnings.c that is pretty much guaranteed.

The other option is to rely on the fact that get_source() is supposed to
use universal newlines.  Then we can find the index of the x and x-1
newlines and print the substring between the two.  That can be done in C
code by checking for the loader, checking for get_source(), calling it,
getting the char buffer, and then just looping through looking for the
needed newlines to find the needed indexes.  Otherwise we can use the
Python API on strings to do what would have been done in pure Python,
but that is a lot of PyObject_Call() usage and seems overly inefficient
if one bothers with coding it in C.  =)
History
Date User Action Args
2007-11-30 07:57:07brett.cannonsetspambayes_score: 0.0106608 -> 0.0106608
recipients: + brett.cannon, nnorwitz, christian.heimes
2007-11-30 07:57:07brett.cannonsetspambayes_score: 0.0106608 -> 0.0106608
messageid: <1196409427.0.0.769312490478.issue1631171@psf.upfronthosting.co.za>
2007-11-30 07:57:06brett.cannonlinkissue1631171 messages
2007-11-30 07:57:05brett.cannoncreate