def defaulterrorhandler(connection, cursor, errorclass, errorvalue):
 error = (errorclass, errorvalue)
 if cursor:
  cursor.messages.append(error)
 else:
  connection.messages.append(error)
 del cursor
 del connection
 raise errorclass, errorvalue

def defaulterrorhandler ( connection , cursor , errorclass , errorvalue ) : error = ( errorclass , errorvalue ) if cursor : cursor . messages . append ( error ) else : connection . messages . append ( error ) del cursor del connection raise errorclass , errorvalue
if cursor is not none .