diff Python/bltinmodule.c @ 2062:d0d0a69b5ca3 legacy-trunk

Added 1995 to copyright message. bltinmodule.c: fixed coerce() nightmare in ternary pow(). modsupport.c (initmodule2): pass METH_FREENAME flag to newmethodobject(). pythonrun.c: move flushline() into and around print_error().
author Guido van Rossum <guido@python.org>
date Wed, 04 Jan 1995 19:12:13 +0000
parents d7e91437f0a2
children 65146b52f16b
line wrap: on
line diff
--- a/Python/bltinmodule.c	Wed Jan 04 19:10:35 1995 +0000
+++ b/Python/bltinmodule.c	Wed Jan 04 19:12:13 1995 +0000
@@ -1,6 +1,6 @@
 /***********************************************************
-Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
-Amsterdam, The Netherlands.
+Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
+The Netherlands.
 
                         All Rights Reserved
 
@@ -922,16 +922,31 @@
 	}
 	if (coerce(&v, &w) != 0)
 		return NULL;
-	if (z!=None) {
-	 	if (coerce(&w, &z) != 0)
-			return NULL;
-		if (coerce(&v, &z) != 0)
-			return NULL;
+	if (z == None) {
+		x = (*v->ob_type->tp_as_number->nb_power)(v, w, z);
 	}
-	x = (*v->ob_type->tp_as_number->nb_power)(v, w, z);
+	else {
+		object *v1, *z1, *w2, *z2;
+		x = NULL;
+		v1 = v;
+		z1 = z;
+		if (coerce(&v1, &z1) != 0)
+			goto error2;
+		w2 = w;
+		z2 = z1;
+	 	if (coerce(&w2, &z2) != 0)
+			goto error1;
+		x = (*v1->ob_type->tp_as_number->nb_power)(v1, w2, z2);
+		DECREF(w2);
+		DECREF(z2);
+	error1:
+		DECREF(v1);
+		DECREF(z1);
+	error2:
+		;
+	}
 	DECREF(v);
 	DECREF(w);
-	if (z!=None) {DECREF(w); DECREF(v); DECREF(z); DECREF(z);}
 	return x;
 }