Mercurial > cpython-lru_cache-weakref
diff Python/ceval.c @ 4594:41857075d45b legacy-trunk
Change the Don Beaudry hack into the Don B + Jim F hack; now, if *any*
base class is special it gets invoked.
Make gcc -Wall happy.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 05 Dec 1996 23:17:11 +0000 |
| parents | 65d2d8e67da3 |
| children | c42379e4653b |
line wrap: on
line diff
--- a/Python/ceval.c Thu Dec 05 23:15:35 1996 +0000 +++ b/Python/ceval.c Thu Dec 05 23:17:11 1996 +0000 @@ -319,8 +319,8 @@ object *owner; { register unsigned char *next_instr; - register int opcode; /* Current opcode */ - register int oparg; /* Current opcode argument, if any */ + register int opcode = 0; /* Current opcode */ + register int oparg = 0; /* Current opcode argument, if any */ register object **stack_pointer; register enum why_code why; /* Reason for block stack unwind */ register int err; /* Error status -- nonzero if error */ @@ -330,8 +330,8 @@ register object *u; register object *t; register frameobject *f; /* Current frame */ - register object **fastlocals; - object *retval; /* Return value */ + register object **fastlocals = NULL; + object *retval = NULL; /* Return value */ #ifdef SUPPORT_OBSOLETE_ACCESS int defmode = 0; /* Default access mode for new variables */ #endif @@ -1793,8 +1793,8 @@ break; } if (b->b_type == SETUP_FINALLY || - b->b_type == SETUP_EXCEPT && - why == WHY_EXCEPTION) { + (b->b_type == SETUP_EXCEPT && + why == WHY_EXCEPTION)) { if (why == WHY_EXCEPTION) { object *exc, *val, *tb; err_fetch(&exc, &val, &tb); @@ -2055,7 +2055,7 @@ { BINOP("__or__", "__ror__", or); if (v->ob_type->tp_as_number != NULL) { - object *x; + object *x = NULL; object * (*f) FPROTO((object *, object *)); if (coerce(&v, &w) != 0) return NULL; @@ -2076,7 +2076,7 @@ { BINOP("__xor__", "__rxor__", xor); if (v->ob_type->tp_as_number != NULL) { - object *x; + object *x = NULL; object * (*f) FPROTO((object *, object *)); if (coerce(&v, &w) != 0) return NULL; @@ -2097,7 +2097,7 @@ { BINOP("__and__", "__rand__", and); if (v->ob_type->tp_as_number != NULL) { - object *x; + object *x = NULL; object * (*f) FPROTO((object *, object *)); if (coerce(&v, &w) != 0) return NULL; @@ -2118,7 +2118,7 @@ { BINOP("__lshift__", "__rlshift__", lshift); if (v->ob_type->tp_as_number != NULL) { - object *x; + object *x = NULL; object * (*f) FPROTO((object *, object *)); if (coerce(&v, &w) != 0) return NULL; @@ -2139,7 +2139,7 @@ { BINOP("__rshift__", "__rrshift__", rshift); if (v->ob_type->tp_as_number != NULL) { - object *x; + object *x = NULL; object * (*f) FPROTO((object *, object *)); if (coerce(&v, &w) != 0) return NULL; @@ -2379,7 +2379,7 @@ return NULL; } - if (call = func->ob_type->tp_call) + if ((call = func->ob_type->tp_call) != NULL) result = (*call)(func, arg, kw); else if (is_instancemethodobject(func) || is_funcobject(func)) result = call_function(func, arg, kw); @@ -2890,22 +2890,6 @@ err_setstr(SystemError, "build_class with non-tuple bases"); return NULL; } - if (gettuplesize(bases) > 0) { - object *base; - base = GETTUPLEITEM(bases, 0); - /* Call the base's *type*, if it is callable. - This code is a hook for Donald Beaudry's type extensions. - In unexended Python it will never be triggered since its - types are not callable. */ - if (base->ob_type->ob_type->tp_call) { - object *args; - object *class; - args = mkvalue("(OOO)", name, bases, methods); - class = call_object((object *)base->ob_type, args); - DECREF(args); - return class; - } - } if (!is_dictobject(methods)) { err_setstr(SystemError, "build_class with non-dictionary"); return NULL; @@ -2917,6 +2901,20 @@ for (i = gettuplesize(bases); --i >= 0; ) { object *base = GETTUPLEITEM(bases, i); if (!is_classobject(base)) { + /* Call the base's *type*, if it is callable. + This code is a hook for Donald Beaudry's + and Jim Fulton's type extensions. In + unexended Python it will never be triggered + since its types are not callable. */ + if (base->ob_type->ob_type->tp_call) { + object *args; + object *class; + args = mkvalue("(OOO)", name, bases, methods); + class = call_object((object *)base->ob_type, + args); + DECREF(args); + return class; + } err_setstr(TypeError, "base is not a class object"); return NULL;
