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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jmike@alum.mit.edu

    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
  • Larry Bates

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

    jmike@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

    Comment

    • Sion Arrowsmith

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

      In article <f67cfca9-dffe-4931-a206-8d96b441a236@e5 3g2000hsa.googl egroups.com>,
      <jmike@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 -- siona@chiark.gr eenend.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

      Comment

      Working...