Message311829
Displaying the source code in tracebacks for Cython-compiled extension modules in IPython no longer works due to PEP 302. Various fixes are possible, the two most obvious ones are:
1. linecache should continue searching for the source file even if loader.get_source() returns None.
2. the method ExtensionFileLoader.get_source() should be removed (instead of being implemented and returning None).
Now why was this broken and how do the above fix that?
When IPython needs to display a traceback, it uses linecache.getlines() to get the source code to display. For Cython extensions, the filename is a correct *relative* filename (it must be a relative filename since Cython does not know where the sources will be after installation).
Since the filename is relative, linecache does not immediately find it, so it looks for a PEP 302 loader. For extension modules (Cython or not), it finds an instance of ExtensionFileLoader. If the loader has a get_source() method, then it uses that to get the sources. Since ExtensionFileLoader.get_source() returns None, linecache stops looking further for sources.
Instead, what should happen is that linecache continues looking for the sources in sys.path where it has a chance of finding them (if they are installed somewhere in sys.path). |
|
Date |
User |
Action |
Args |
2018-02-08 11:55:24 | jdemeyer | set | recipients:
+ jdemeyer, erik.bray |
2018-02-08 11:55:24 | jdemeyer | set | messageid: <1518090924.55.0.467229070634.issue32797@psf.upfronthosting.co.za> |
2018-02-08 11:55:24 | jdemeyer | link | issue32797 messages |
2018-02-08 11:55:24 | jdemeyer | create | |
|