[pypy-svn] r34966 - pypy/dist/pypy/rpython
arigo at codespeak.net
arigo at codespeak.net
Sat Nov 25 17:38:25 CET 2006
Author: arigo
Date: Sat Nov 25 17:38:23 2006
New Revision: 34966
Modified:
pypy/dist/pypy/rpython/rmodel.py
Log:
Fix missing_rtype_operation()'s error message. The 'hop.spaceop.opname'
may differ from the name under which the missing_rtype_operation was
looked up; see e.g. the error message that was given by float("3.14") .
Modified: pypy/dist/pypy/rpython/rmodel.py
==============================================================================
--- pypy/dist/pypy/rpython/rmodel.py (original)
+++ pypy/dist/pypy/rpython/rmodel.py Sat Nov 25 17:38:23 2006
@@ -299,24 +299,22 @@
# ____________________________________________________________
-def missing_rtype_operation(self, hop):
- raise MissingRTypeOperation("unimplemented operation: '%s' on %r" % (
- hop.spaceop.opname, self))
-
-def setattr_default(obj, attr, value):
- if not hasattr(obj, attr):
- setattr(obj, attr, value)
+def make_missing_op(rcls, opname):
+ attr = 'rtype_' + opname
+ if not hasattr(rcls, attr):
+ def missing_rtype_operation(self, hop):
+ raise MissingRTypeOperation("unimplemented operation: "
+ "'%s' on %r" % (opname, self))
+ setattr(rcls, attr, missing_rtype_operation)
for opname in annmodel.UNARY_OPERATIONS:
- setattr_default(Repr, 'rtype_' + opname, missing_rtype_operation)
+ make_missing_op(Repr, opname)
for opname in annmodel.BINARY_OPERATIONS:
- setattr_default(pairtype(Repr, Repr),
- 'rtype_' + opname, missing_rtype_operation)
+ make_missing_op(pairtype(Repr, Repr), opname)
# not in BINARY_OPERATIONS
-setattr_default(pairtype(Repr, Repr),
- 'rtype_contains', missing_rtype_operation)
+make_missing_op(pairtype(Repr, Repr), 'contains')
class __extend__(pairtype(Repr, Repr)):
def convert_from_to((r_from, r_to), v, llops):
More information about the Pypy-commit
mailing list