]> granicus.if.org Git - python/commitdiff
Ouch. The wrapper for __rpow__ was the same as for __pow__, resulting
authorGuido van Rossum <guido@python.org>
Fri, 28 Sep 2001 22:58:52 +0000 (22:58 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 28 Sep 2001 22:58:52 +0000 (22:58 +0000)
in bizarre outcomes.  Test forthcoming.

Objects/typeobject.c

index ac201d58909260911c52b41acc9fbc4d4b7c0569..b8a459302cd0e4b10da24bbc1e179f99a1e51b9a 100644 (file)
@@ -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} \
 }