[pypy-commit] pypy translation-cleanup: Flowspacify WITH_CLEANUP
rlamy
noreply at buildbot.pypy.org
Sun Sep 23 18:19:35 CEST 2012
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: translation-cleanup
Changeset: r57484:9d4fd9044400
Date: 2012-09-23 04:51 +0100
http://bitbucket.org/pypy/pypy/changeset/9d4fd9044400/
Log: Flowspacify WITH_CLEANUP
+ Kill FSFrame.call_context_manager_exitfunction()
diff --git a/pypy/objspace/flow/flowcontext.py b/pypy/objspace/flow/flowcontext.py
--- a/pypy/objspace/flow/flowcontext.py
+++ b/pypy/objspace/flow/flowcontext.py
@@ -555,7 +555,8 @@
self.pushvalue(w_result)
def WITH_CLEANUP(self, oparg, next_instr):
- # see comment in END_FINALLY for stack state
+ # Note: RPython context managers receive None in lieu of tracebacks
+ # and cannot suppress the exception.
# This opcode changed a lot between CPython versions
if (self.pycode.magic >= 0xa0df2ef
# Implementation since 2.7a0: 62191 (introduce SETUP_WITH)
@@ -572,25 +573,17 @@
raise NotImplementedError("WITH_CLEANUP for CPython <= 2.4")
unroller = self.space.interpclass_w(w_unroller)
+ w_None = self.space.w_None
is_app_exc = (unroller is not None and
isinstance(unroller, SApplicationException))
if is_app_exc:
operr = unroller.operr
- w_traceback = self.space.wrap(operr.get_traceback())
- w_suppress = self.call_contextmanager_exit_function(
- w_exitfunc,
- operr.w_type,
- operr.get_w_value(self.space),
- w_traceback)
- if self.space.is_true(w_suppress):
- # __exit__() returned True -> Swallow the exception.
- self.settopvalue(self.space.w_None)
+ # The annotator won't allow to merge exception types with None.
+ # Replace it with the exception value...
+ self.space.call_function(w_exitfunc,
+ operr.w_value, operr.w_value, w_None)
else:
- self.call_contextmanager_exit_function(
- w_exitfunc,
- self.space.w_None,
- self.space.w_None,
- self.space.w_None)
+ self.space.call_function(w_exitfunc, w_None, w_None, w_None)
def LOAD_GLOBAL(self, nameindex, next_instr):
w_result = self.space.find_global(self.w_globals, self.getname_u(nameindex))
@@ -623,16 +616,6 @@
def argument_factory(self, *args):
return ArgumentsForTranslation(self.space, *args)
- def call_contextmanager_exit_function(self, w_func, w_typ, w_val, w_tb):
- if w_typ is not self.space.w_None:
- # The annotator won't allow to merge exception types with None.
- # Replace it with the exception value...
- w_typ = w_val
- self.space.call_function(w_func, w_typ, w_val, w_tb)
- # Return None so that the flow space statically knows that we didn't
- # swallow the exception
- return self.space.w_None
-
### Frame blocks ###
class SFlowException(SApplicationException):
More information about the pypy-commit
mailing list