[pypy-svn] r9026 - pypy/dist/pypy/objspace/flow
pedronis at codespeak.net
pedronis at codespeak.net
Wed Feb 9 13:10:54 CET 2005
Author: pedronis
Date: Wed Feb 9 13:10:54 2005
New Revision: 9026
Modified:
pypy/dist/pypy/objspace/flow/objspace.py
Log:
avoid method-wrappers to appear as constant in a flow graph and during its contruction,
- construction time problem is that they compare by identity and replaying will produce mismatching
ops because of this
- problem for translation tools down the chain is that method-wrappers offer very poor introspectio,
so it hard to build code to (re)construct them
Modified: pypy/dist/pypy/objspace/flow/objspace.py
==============================================================================
--- pypy/dist/pypy/objspace/flow/objspace.py (original)
+++ pypy/dist/pypy/objspace/flow/objspace.py Wed Feb 9 13:10:54 2005
@@ -11,6 +11,13 @@
class UnwrapException(Exception):
"Attempted to unwrap a Variable."
+class WrapException(Exception):
+ """Attempted wrapping of a type that cannot sanely appear in flow graph or during its construction"""
+
+# method-wrappers
+method_wrapper = type(complex.real.__get__)
+
+
# ______________________________________________________________________
class FlowObjSpace(ObjSpace):
"""NOT_RPYTHON.
@@ -97,6 +104,10 @@
def wrap(self, obj):
if isinstance(obj, (Variable, Constant)) and obj is not UNDEFINED:
raise TypeError("already wrapped: " + repr(obj))
+ # method-wrapper have ill-defined comparison and introspection
+ # to appear in a flow graph
+ if type(obj) is method_wrapper:
+ raise WrapException
return Constant(obj)
def int_w(self, w_obj):
@@ -391,7 +402,12 @@
raise flowcontext.OperationThatShouldNotBePropagatedError(
self.wrap(etype), self.wrap(msg))
else:
- return self.wrap(result)
+ try:
+ return self.wrap(result)
+ except WrapException:
+ # type cannot sanely appear in flow graph,
+ # store operation with variable result instead
+ pass
#print >> sys.stderr, 'Variable operation', name, args_w
w_result = self.do_operation(name, *args_w)
More information about the Pypy-commit
mailing list