The Fancy Traceback display can fail to work if the
source files of all files in the traceback do not exist.
This can be the case if the .py files have since been
removed, or if the .py files are not in the same path
as the .pyc are imported.
In my scenario, python is installed from an rpm, the
rpm pre-compiles the .py files in the library into .pyc
files, however it does all of this in a temporary
directory which no longer exists in my installed
system. The .pyc files claim their source file is
actually in that temporary directory. So if I look at
the module ihooks, I see its source file does not
exist, even though it is in the same directory as
The problem appears to be that MiscUtils/inspect.py
getsourcefile() tries to find the file on the sys.path.
However if the filename does not exist on that path,
it does not return anything, which results in cgitb.py
failing when it tries to interpret None as a string.
This patch simply adds a 'return filename' at the end
of inspect.py:getsourcefile() so it will not return None.
Log in to post a comment.