Here is a new version of _Py_DisplaySourceLine() using
PyTokenizer_FindEncoding() to read the coding header, and
PyFile_FromFd() to create an "unicode-awake" file. The code could be
optimized, but it least it displays correctly the file line ;-)
The code is based on the original _Py_DisplaySourceLine() and
call_find_module() (import.c).
Notes:
* The code is young and new, it might be delayed until python 3.1
* Some functions may raise new exceptions (eg. MemoryError). I don't
know how Python will react if an exception is raised during
PyTraceBack_Print() ?
* The return code is 0 for success, but is it -1 or 1 for an error? It
looks like error is "result != 0", so both -1 and 1 should be valid. I
used -1. |