469,623 Members | 1,850 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,623 developers. It's quick & easy.

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

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
Jul 9 '08 #1
2 2862
jm***@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
Jul 9 '08 #2
In article <f6**********************************@e53g2000hsa. googlegroups.com>,
<jm***@alum.mit.eduwrote:
>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.

--
\S -- si***@chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
"Frankly I have no feelings towards penguins one way or the other"
-- Arthur C. Clarke
her nu becomež se bera eadward ofdun hlęddre heafdes bęce bump bump bump
Jul 10 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Elmar Haneke | last post: by
3 posts views Thread by Daniel Lidström | last post: by
4 posts views Thread by anthony.wolfe | last post: by
1 post views Thread by joop23 | last post: by
reply views Thread by =?Utf-8?B?a3Jpc2huYQ==?= | last post: by
35 posts views Thread by eliben | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.