User-defined exception: "global name 'TestRunError' is not defined"

Larry Bates larry.bates at websafe.com`
Wed Jul 9 16:43:08 EDT 2008


jmike at alum.mit.edu wrote:
> I'm using some legacy code that has a user-defined exception in it.
> 
> The top level program includes this line
> 
> from TestRunError import *
> 
> It also imports several other modules.  These other modules do not
> explicitly import TestRunError.  TestRunError is raised in various
> places throughout the modules.
> 
> There are a few cases where something goes wrong with the program and
> I get this error:
> 
> FATAL ERROR: global name 'TestRunError' is not defined
> 
> I realize this is kind of a silly question to ask in the general sense
> without showing more of the code, but does anyone have any suggestions
> as to the most likely causes of this error coming up?  Could it be
> something like an error happening where it is not explicitly in a try
> block, or an error happening while I'm already in an except block, or
> something like that?
> 
> Thanks,
>   --JMike

Please post the entire traceback and we might actually be able to help.

The traceback will show a line number where it failed, you can look to see
what is going on at the time.

It is more likely a scoping issue where TestRunError isn't defined in the scope 
where the exception is being raised.

-Larry



More information about the Python-list mailing list