summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-09-28 22:58:52 (GMT)
committerGuido van Rossum <guido@python.org>2001-09-28 22:58:52 (GMT)
commit9bea3abf0d7c658a95a92a295c82d5bf0b583f08 (patch)
tree1fbc786d149e034480305efda8881daffc9aa2d7
parent7988e0249c8c72d12cbabb69bfdf310da79c1ea5 (diff)
downloadcpython-9bea3abf0d7c658a95a92a295c82d5bf0b583f08.zip
cpython-9bea3abf0d7c658a95a92a295c82d5bf0b583f08.tar.gz
cpython-9bea3abf0d7c658a95a92a295c82d5bf0b583f08.tar.bz2
Ouch. The wrapper for __rpow__ was the same as for __pow__, resulting
in bizarre outcomes. Test forthcoming.
-rw-r--r--Objects/typeobject.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index ac201d5..b8a4593 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -1888,6 +1888,20 @@ wrap_ternaryfunc(PyObject *self, PyObject *args, void *wrapped)
return (*func)(self, other, third);
}
+static PyObject *
+wrap_ternaryfunc_r(PyObject *self, PyObject *args, void *wrapped)
+{
+ ternaryfunc func = (ternaryfunc)wrapped;
+ PyObject *other;
+ PyObject *third = Py_None;
+
+ /* Note: This wrapper only works for __pow__() */
+
+ if (!PyArg_ParseTuple(args, "O|O", &other, &third))
+ return NULL;
+ return (*func)(other, self, third);
+}
+
#undef TERNARY
#define TERNARY(NAME, OP) \
static struct wrapperbase tab_##NAME[] = { \
@@ -1895,7 +1909,7 @@ static struct wrapperbase tab_##NAME[] = { \
(wrapperfunc)wrap_ternaryfunc, \
"x.__" #NAME "__(y, z) <==> " #OP}, \
{"__r" #NAME "__", \
- (wrapperfunc)wrap_ternaryfunc, \
+ (wrapperfunc)wrap_ternaryfunc_r, \
"y.__r" #NAME "__(x, z) <==> " #OP}, \
{0} \
}