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

Discussion in 'Python' started by jmike@alum.mit.edu, Jul 9, 2008.

  1. Guest

    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, 2008
    #1
    1. Advertising

  2. In article <>,
    <> 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.


    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 -- -- 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
     
    Sion Arrowsmith, Jul 10, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Oodini
    Replies:
    1
    Views:
    1,802
    Keith Thompson
    Sep 27, 2005
  2. Angel Tsankov
    Replies:
    1
    Views:
    878
    Victor Bazarov
    Apr 5, 2006
  3. Ò»Ê×Ê«
    Replies:
    1
    Views:
    306
    Terry Reedy
    Feb 26, 2009
  4. Visco Shaun
    Replies:
    0
    Views:
    251
    Visco Shaun
    Sep 29, 2009
  5. Richard Maher

    User-Defined and/or User-Triggered Events

    Richard Maher, Mar 3, 2007, in forum: Javascript
    Replies:
    3
    Views:
    240
    Richard Maher
    Mar 4, 2007
Loading...

Share This Page