Exception difference 2.4 ==> 2.5

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • D'Arcy J.M. Cain

    Exception difference 2.4 ==> 2.5

    I am having a strange problem and I can't seem to zero in on it. I am
    also having trouble reducing it to a small enough snippet that I can
    post here. I think that I am doing what the more complex script does
    but none of my attempts fail. So, here is a description just in case
    someone has seen something that smells like this and can suggest some
    areas to do further poking.

    I have a class that subclasses xmlrpcserver.Re questHandler. It has a
    method that takes a function name that it looks up with getattr. It
    then calls the looked up method in this try/except block:

    try:
    return server_method(p kt)
    except Exception, failure:
    syslog(LOG_WARN ING, "%s, %s" % (Exception, failure))
    self.print_tb(s ys.exc_info())

    try: fault = self.faultConve rter.errorToFau lt(failure)
    except Exception, err:
    syslog(LOG_ERR, "Error processing failure: %r" % err)
    fault = xmlrpclib.Fault (8002, "Internal error")

    syslog(LOG_DEBU G, "Converted failure %r to fault %r (%r)" %
    \ (failure, fault, failure))

    if fault.faultCode < 10000:
    syslog(LOG_ERR, "Unconverte d fault: %r" % failure)

    return fault

    This class is then subclassed by another class that adds the methods
    that are to be looked up. Those methods may raise exceptions if there
    are errors.

    Under Python 2.4 this works fine. If an exception is raised in the
    looked up method it gets handled by this code just fine. Under 2.5,
    however, the exception is not caught here. It's as if there was no
    try/except here at all.

    I'm not sure if I have left off some critical piece of information or
    just littered this post with red herrings. I'm open to both
    reasoned suggestions as well as wild speculation.

    --
    D'Arcy J.M. Cain <darcy@druid.ne t | Democracy is three wolves
    http://www.druid.net/darcy/ | and a sheep voting on
    +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
  • Ross Ridge

    #2
    Re: Exception difference 2.4 ==&gt; 2.5

    D'Arcy J.M. Cain <darcy@druid.ne twrote:
    >Under Python 2.4 this works fine. If an exception is raised in the
    >looked up method it gets handled by this code just fine. Under 2.5,
    >however, the exception is not caught here. It's as if there was no
    >try/except here at all.
    Python 2.5 changed the exception hierarchy a bit. The Exception class
    is no longer at the root and now inheirits from BaseException. If the
    exception being thrown was KeyboardInterru pt or SystemExit then it won't
    be caught by your code.

    Ross Ridge

    --
    l/ // Ross Ridge -- The Great HTMU
    [oo][oo] rridge@csclub.u waterloo.ca
    -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/
    db //

    Comment

    • D'Arcy J.M. Cain

      #3
      Re: Exception difference 2.4 ==&gt; 2.5

      On Wed, 19 Nov 2008 01:57:37 -0500
      Ross Ridge <rridge@csclub. uwaterloo.cawro te:
      D'Arcy J.M. Cain <darcy@druid.ne twrote:
      Under Python 2.4 this works fine. If an exception is raised in the
      looked up method it gets handled by this code just fine. Under 2.5,
      however, the exception is not caught here. It's as if there was no
      try/except here at all.
      >
      Python 2.5 changed the exception hierarchy a bit. The Exception class
      is no longer at the root and now inheirits from BaseException. If the
      exception being thrown was KeyboardInterru pt or SystemExit then it won't
      be caught by your code.
      Yes, I was aware of that but the error not being caught is
      RuntimeError. I also tried a bare "except" just to be sure but same
      behaviour.

      --
      D'Arcy J.M. Cain <darcy@druid.ne t | Democracy is three wolves
      http://www.druid.net/darcy/ | and a sheep voting on
      +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.

      Comment

      Working...