# Script randomly exits for seemingly no reason with strange traceback

Steven D'Aprano steve+comp.lang.python at pearwood.info
Fri Feb 3 18:25:32 EST 2012

On Fri, 03 Feb 2012 14:14:57 -0600, Andrew Berg wrote:

> It's a rare occurrence, but sometimes my script will terminate and I get
> this:
>
> Traceback (most recent call last):
>   File "C:\path\to\script\script.py", line 992, in <module>
>
> That's it. And the line number is always the last line of the file
> (which in my case is a blank line).

Is it reproducible? That is, can you demonstrate a script which will
*always* show this failure?

> I have not seen this on Linux (where
> my script can run for days or weeks on a remote server), but only on
> Windows where I do most of my testing (and it typically only runs for
> minutes at a time). There may be bugs in my program, but I don't see how
> Python should ever print a traceback like this.

Which version of Python, which version of Windows?

If you upgrade Python, does the problem go away?

If you perturb your script (add a few blank lines at the end, or a
comment), does it go away?

--
Steven