Example #1
0
 def last_operr(space, frame):
     while frame:
         last = frame.last_exception
         if (last is not None and
             (not frame.hide() or
              last is get_cleared_operation_error(space))):
                 return last
         frame = frame.f_backref()
     return None
Example #2
0
 def last_operr(space, frame):
     while frame:
         last = frame.last_exception
         if (last is not None
                 and (not frame.hide()
                      or last is get_cleared_operation_error(space))):
             return last
         frame = frame.f_backref()
     return None
Example #3
0
 def clear_sys_exc_info(self):
     # Find the frame out of which sys_exc_info() would return its result,
     # and hack this frame's last_exception to become the cleared
     # OperationError (which is different from None!).
     frame = self.gettopframe_nohidden()
     while frame:
         if frame.last_exception is not None:
             frame.last_exception = get_cleared_operation_error(self.space)
             break
         frame = self.getnextframe_nohidden(frame)
Example #4
0
 def sys_exc_info(self):  # attn: the result is not the wrapped sys.exc_info() !!!
     """Implements sys.exc_info().
     Return an OperationError instance or None."""
     frame = self.gettopframe()
     while frame:
         if frame.last_exception is not None:
             if not frame.hide() or frame.last_exception is get_cleared_operation_error(self.space):
                 return frame.last_exception
         frame = frame.f_backref()
     return None
Example #5
0
 def sys_exc_info(self): # attn: the result is not the wrapped sys.exc_info() !!!
     """Implements sys.exc_info().
     Return an OperationError instance or None."""
     frame = self.gettopframe()
     while frame:
         if frame.last_exception is not None:
             if (not frame.hide() or
                     frame.last_exception is
                         get_cleared_operation_error(self.space)):
                 return frame.last_exception
         frame = frame.f_backref()
     return None
Example #6
0
 def _exc_info_unroll(self, space, for_hidden=False):
     """Return the most recent OperationError being handled in the
     call stack
     """
     frame = self
     while frame:
         last = frame.last_exception
         if last is not None:
             if last is get_cleared_operation_error(self.space):
                 break
             if for_hidden or not frame.hide():
                 return last
         frame = frame.f_backref()
     return None
Example #7
0
 def _exc_info_unroll(self, space, for_hidden=False):
     """Return the most recent OperationError being handled in the
     call stack
     """
     frame = self
     while frame:
         last = frame.last_exception
         if last is not None:
             if last is get_cleared_operation_error(self.space):
                 break
             if for_hidden or not frame.hide():
                 return last
         frame = frame.f_backref()
     return None
Example #8
0
    def sys_exc_info(self, for_hidden=False):
        """Implements sys.exc_info().
        Return an OperationError instance or None.

        Ignores exceptions within hidden frames unless for_hidden=True
        is specified.

        # NOTE: the result is not the wrapped sys.exc_info() !!!

        """
        frame = self.gettopframe()
        while frame:
            if frame.last_exception is not None:
                if ((for_hidden or not frame.hide()) or
                        frame.last_exception is
                            get_cleared_operation_error(self.space)):
                    return frame.last_exception
            frame = frame.f_backref()
        return None
Example #9
0
 def descr_init(self, w_callable, __args__):
     if self.sthread is not None:
         raise geterror(self.space, "continulet already __init__ialized")
     sthread = build_sthread(self.space)
     #
     # hackish: build the frame "by hand", passing it the correct arguments
     space = self.space
     w_args, w_kwds = __args__.topacked()
     bottomframe = space.createframe(get_entrypoint_pycode(space), get_w_module_dict(space), None)
     bottomframe.locals_stack_w[0] = space.wrap(self)
     bottomframe.locals_stack_w[1] = w_callable
     bottomframe.locals_stack_w[2] = w_args
     bottomframe.locals_stack_w[3] = w_kwds
     bottomframe.last_exception = get_cleared_operation_error(space)
     self.bottomframe = bottomframe
     #
     global_state.origin = self
     self.sthread = sthread
     h = sthread.new(new_stacklet_callback)
     post_switch(sthread, h)
Example #10
0
 def descr_init(self, w_callable, __args__):
     if self.sthread is not None:
         raise geterror(self.space, "continulet already __init__ialized")
     sthread = build_sthread(self.space)
     #
     # hackish: build the frame "by hand", passing it the correct arguments
     space = self.space
     w_args, w_kwds = __args__.topacked()
     bottomframe = space.createframe(get_entrypoint_pycode(space),
                                     get_w_module_dict(space), None)
     bottomframe.locals_cells_stack_w[0] = self
     bottomframe.locals_cells_stack_w[1] = w_callable
     bottomframe.locals_cells_stack_w[2] = w_args
     bottomframe.locals_cells_stack_w[3] = w_kwds
     bottomframe.last_exception = get_cleared_operation_error(space)
     self.bottomframe = bottomframe
     #
     global_state.origin = self
     self.sthread = sthread
     h = sthread.new(new_stacklet_callback)
     post_switch(sthread, h)