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

J

jmike

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
 
S

Sion Arrowsmith

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.

The import line imports TestRunError into the "global" namespeace
of the top level program module *only*. It is not magically
propogated to the other modules imported -- if they want to use
TestRunError themselves, they have to import it, otherwise this
happens:
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?

The cause is whoever wrote the legacy code not understanding
how to program in Python.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top