Brett Cannon added the comment: 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. =) _____________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue1631171> _____________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com