Author: Antonio Cuni <[email protected]>
Branch: sanitize-finally-stack
Changeset: r55009:6511d86d1c8f
Date: 2012-05-10 17:05 +0200
http://bitbucket.org/pypy/pypy/changeset/6511d86d1c8f/
Log: (antocuni, arigo around): implement this logic for the flow
objspace, and rename it to be even more obscure so that it's clear
that it should not be used generally
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -801,7 +801,13 @@
return obj
interp_w._annspecialcase_ = 'specialize:arg(1)'
- def _check_interp_w_or_none(self, RequiredClass, w_obj):
+ def _check_constant_interp_w_or_w_None(self, RequiredClass, w_obj):
+ """
+ This method should NOT be called unless you are really sure about
+ it. It is used inside the implementation of end_finally() in
+ pyopcode.py, and it's there so that it can be overridden by the
+ FlowObjSpace.
+ """
if self.is_w(w_obj, self.w_None):
return True
obj = self.interpclass_w(w_obj)
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -612,7 +612,7 @@
w_top = self.popvalue()
# the following logic is a mess for the flow objspace,
# so we hide it specially in the space :-/
- if self.space._check_interp_w_or_none(SuspendedUnroller, w_top):
+ if self.space._check_constant_interp_w_or_w_None(SuspendedUnroller,
w_top):
# case of a finally: block
unroller = self.space.interpclass_w(w_top)
return unroller
diff --git a/pypy/objspace/flow/objspace.py b/pypy/objspace/flow/objspace.py
--- a/pypy/objspace/flow/objspace.py
+++ b/pypy/objspace/flow/objspace.py
@@ -204,6 +204,14 @@
return obj
return None
+ def _check_constant_interp_w_or_w_None(self, RequiredClass, w_obj):
+ """
+ WARNING: this implementation is not complete at all. It's just enough
+ to be used by end_finally() inside pyopcode.py.
+ """
+ return w_obj == self.w_None or (isinstance(w_obj, Constant) and
+ isinstance(w_obj.value, RequiredClass))
+
def getexecutioncontext(self):
return getattr(self, 'executioncontext', None)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit