This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jdemeyer
Recipients erik.bray, jdemeyer
Date 2018-02-08.11:55:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1518090924.55.0.467229070634.issue32797@psf.upfronthosting.co.za>
In-reply-to
Content
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).
History
Date User Action Args
2018-02-08 11:55:24jdemeyersetrecipients: + jdemeyer, erik.bray
2018-02-08 11:55:24jdemeyersetmessageid: <1518090924.55.0.467229070634.issue32797@psf.upfronthosting.co.za>
2018-02-08 11:55:24jdemeyerlinkissue32797 messages
2018-02-08 11:55:24jdemeyercreate