From 6d023c98b06e8b4558f3558335433f371a89cc9b Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 4 Jan 1995 19:12:13 +0000 Subject: 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(). --- Python/bltinmodule.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'Python/bltinmodule.c') diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 39dcc411b2..c553be60aa 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -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 @@ builtin_pow(self, args) } 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); + } + 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: + ; } - x = (*v->ob_type->tp_as_number->nb_power)(v, w, z); DECREF(v); DECREF(w); - if (z!=None) {DECREF(w); DECREF(v); DECREF(z); DECREF(z);} return x; } -- cgit v1.2.1