Author: Mariano Anaya <[email protected]>
Branch: py3.5
Changeset: r91892:0e1f2cd91ced
Date: 2017-07-16 14:16 +0200
http://bitbucket.org/pypy/pypy/changeset/0e1f2cd91ced/
Log: (arigo, rmariano)
Fixing regression with non-started generator receiving non-None,
should always raise TypeError.
diff --git a/pypy/interpreter/generator.py b/pypy/interpreter/generator.py
--- a/pypy/interpreter/generator.py
+++ b/pypy/interpreter/generator.py
@@ -109,11 +109,16 @@
#
# Optimization only: after we've started a Coroutine without
# CO_YIELD_INSIDE_TRY, then Coroutine._finalize_() will be a no-op
- if (isinstance(self, Coroutine)
- and frame.last_instr == -1
- and not (self.pycode.co_flags & CO_YIELD_INSIDE_TRY)):
- rgc.may_ignore_finalizer(self)
- #
+ if frame.last_instr == -1:
+ if (isinstance(self, Coroutine) and
+ not (self.pycode.co_flags & CO_YIELD_INSIDE_TRY)):
+ rgc.may_ignore_finalizer(self)
+
+ if (not space.is_w(w_arg_or_err, space.w_None) and
+ not isinstance(w_arg_or_err, SApplicationException)):
+ raise oefmt(space.w_TypeError,
+ "can't send non-None value to a just-started %s",
+ self.KIND)
self.running = True
try:
w_result = frame.execute_frame(self, w_arg_or_err)
@@ -158,12 +163,7 @@
return frame.handle_generator_error(w_arg_or_err.operr)
last_instr = jit.promote(frame.last_instr)
- if last_instr == -1:
- if not space.is_w(w_arg_or_err, space.w_None):
- raise oefmt(space.w_TypeError,
- "can't send non-None value to a just-started %s",
- self.KIND)
- else:
+ if last_instr != -1:
frame.pushvalue(w_arg_or_err)
return r_uint(last_instr + 1)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit