Re: Frozen python scripts and stack traces

Guido.van.Rossum@cwi.nl
Fri, 17 Dec 1993 10:58:37 +0100

> I really start using the capability of freezing python scripts, since the
> module libraries are hard to maintain and distribute on all machines.
> However, when a frozen script prints a stacktrace after an exception has
> been raised and not caught, it actually prints garbage and hangs since it
> tries to print lines of files that don't exist. I didn't look at the code,
> but I'm sure that shouldn't be too hard to fix.

Hmm. When I try this on the one 0.9.9 frozen script I have lying
around, all it does is print nothing (as I would expect) for files it
cannot find. It doesn't print garbage and it doesn't hang. If it
really *hangs*, I suggest you have a closer look at your system to see
why. The stack traceback printing code is fairly robust as far as I
can remember.

One detail you may not know: if it can't open the filename as found in
the code object, it searches sys.path for the basename. This vastly
increases the chance of finding the file (e.g. when the code object
contains a relative filename) but might cause confusion if your script
was frozen from a different version than the version in finds along
$PYTHONPATH. Finally, note that the source is not included in the
frozen binary.

Perhaps it would be better not to attempt to print lines from the file
at all for frozen modules?

--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>