#37 FancyTraceback fails if source missing

MiscUtils (2)

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.


  • Stuart Donaldson

    Patch to MiscUtils/inspect.py, fixes FancyTraceback when a source file is missing.

  • Stuart Donaldson

    • labels: --> MiscUtils
  • Stuart Donaldson

    • assigned_to: nobody --> stuartd
  • Stuart Donaldson

    Logged In: YES

    This patch is being worked on by the developer listed in the
    Assigned field. A resolution should be forthcoming.

    If you have any questions or comments on this item, please
    contact the developer.

  • Stuart Donaldson

    • status: open --> closed
  • Stuart Donaldson

    Logged In: YES

    Resolved and committed to CVS.


Log in to post a comment.