[pypy-svn] r8785 - in pypy/dist/pypy/objspace: . std
pedronis at codespeak.net
pedronis at codespeak.net
Tue Feb 1 14:17:27 CET 2005
Author: pedronis
Date: Tue Feb 1 14:17:27 2005
New Revision: 8785
Modified:
pypy/dist/pypy/objspace/descroperation.py
pypy/dist/pypy/objspace/std/objspace.py
Log:
class C:
def __pow__(x,y):
return y
c = C()
c ** 1
works
Modified: pypy/dist/pypy/objspace/descroperation.py
==============================================================================
--- pypy/dist/pypy/objspace/descroperation.py (original)
+++ pypy/dist/pypy/objspace/descroperation.py Tue Feb 1 14:17:27 2005
@@ -200,13 +200,18 @@
w_obj1, w_obj2 = w_obj2, w_obj1
w_left_impl, w_right_impl = w_right_impl, w_left_impl
if w_left_impl is not None:
- w_res = space.get_and_call_function(w_left_impl, w_obj1, w_obj2,
- w_obj3)
+ if space.is_w(w_obj3, space.w_None):
+ w_res = space.get_and_call_function(w_left_impl, w_obj1, w_obj2)
+ else:
+ w_res = space.get_and_call_function(w_left_impl, w_obj1, w_obj2, w_obj3)
if _check_notimplemented(space, w_res):
return w_res
if w_right_impl is not None:
- w_res = space.get_and_call_function(w_right_impl, w_obj2, w_obj1,
- w_obj3)
+ if space.is_w(w_obj3, space.w_None):
+ w_res = space.get_and_call_function(w_right_impl, w_obj2, w_obj1)
+ else:
+ w_res = space.get_and_call_function(w_right_impl, w_obj2, w_obj1,
+ w_obj3)
if _check_notimplemented(space, w_res):
return w_res
Modified: pypy/dist/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/dist/pypy/objspace/std/objspace.py (original)
+++ pypy/dist/pypy/objspace/std/objspace.py Tue Feb 1 14:17:27 2005
@@ -404,10 +404,10 @@
# add all regular multimethods to StdObjSpace
for _name, _symbol, _arity, _specialnames in ObjSpace.MethodTable:
if not hasattr(StdObjSpace.MM, _name):
-## if isinstance(getattr(StdObjSpace, _name, None), MultiMethod):
-## mm = getattr(StdObjSpace, _name)
-## else:
- mm = MultiMethod(_symbol, _arity, _specialnames)
+ if _name == 'pow':
+ mm = MultiMethod(_symbol, _arity, _specialnames, defaults=(None,))
+ else:
+ mm = MultiMethod(_symbol, _arity, _specialnames)
setattr(StdObjSpace.MM, _name, mm)
if not hasattr(StdObjSpace, _name):
setattr(StdObjSpace, _name, getattr(StdObjSpace.MM, _name))
More information about the Pypy-commit
mailing list