コード例 #1
0
 def _leak_stopiteration(self, e):
     # Check for __future__ generator_stop and conditionally turn
     # a leaking StopIteration into RuntimeError (with its cause
     # set appropriately).
     space = self.space
     if self.pycode.co_flags & (consts.CO_FUTURE_GENERATOR_STOP
                                | consts.CO_COROUTINE
                                | consts.CO_ITERABLE_COROUTINE):
         e2 = OperationError(
             space.w_RuntimeError,
             space.newtext("%s raised StopIteration" % self.KIND))
         e2.chain_exceptions(space, e)
         e2.set_cause(space, e.get_w_value(space))
         e2.record_context(space, space.getexecutioncontext())
         raise e2
     else:
         space.warn(
             space.newunicode(u"generator '%s' raised StopIteration" %
                              self.get_qualname()),
             space.w_PendingDeprecationWarning)