mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
This commit is contained in:
parent
3afb5959aa
commit
150b2df682
1 changed files with 26 additions and 28 deletions
|
@ -319,8 +319,8 @@ eval_code2(co, globals, locals,
|
||||||
object *owner;
|
object *owner;
|
||||||
{
|
{
|
||||||
register unsigned char *next_instr;
|
register unsigned char *next_instr;
|
||||||
register int opcode; /* Current opcode */
|
register int opcode = 0; /* Current opcode */
|
||||||
register int oparg; /* Current opcode argument, if any */
|
register int oparg = 0; /* Current opcode argument, if any */
|
||||||
register object **stack_pointer;
|
register object **stack_pointer;
|
||||||
register enum why_code why; /* Reason for block stack unwind */
|
register enum why_code why; /* Reason for block stack unwind */
|
||||||
register int err; /* Error status -- nonzero if error */
|
register int err; /* Error status -- nonzero if error */
|
||||||
|
@ -330,8 +330,8 @@ eval_code2(co, globals, locals,
|
||||||
register object *u;
|
register object *u;
|
||||||
register object *t;
|
register object *t;
|
||||||
register frameobject *f; /* Current frame */
|
register frameobject *f; /* Current frame */
|
||||||
register object **fastlocals;
|
register object **fastlocals = NULL;
|
||||||
object *retval; /* Return value */
|
object *retval = NULL; /* Return value */
|
||||||
#ifdef SUPPORT_OBSOLETE_ACCESS
|
#ifdef SUPPORT_OBSOLETE_ACCESS
|
||||||
int defmode = 0; /* Default access mode for new variables */
|
int defmode = 0; /* Default access mode for new variables */
|
||||||
#endif
|
#endif
|
||||||
|
@ -1793,8 +1793,8 @@ eval_code2(co, globals, locals,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (b->b_type == SETUP_FINALLY ||
|
if (b->b_type == SETUP_FINALLY ||
|
||||||
b->b_type == SETUP_EXCEPT &&
|
(b->b_type == SETUP_EXCEPT &&
|
||||||
why == WHY_EXCEPTION) {
|
why == WHY_EXCEPTION)) {
|
||||||
if (why == WHY_EXCEPTION) {
|
if (why == WHY_EXCEPTION) {
|
||||||
object *exc, *val, *tb;
|
object *exc, *val, *tb;
|
||||||
err_fetch(&exc, &val, &tb);
|
err_fetch(&exc, &val, &tb);
|
||||||
|
@ -2055,7 +2055,7 @@ or(v, w)
|
||||||
{
|
{
|
||||||
BINOP("__or__", "__ror__", or);
|
BINOP("__or__", "__ror__", or);
|
||||||
if (v->ob_type->tp_as_number != NULL) {
|
if (v->ob_type->tp_as_number != NULL) {
|
||||||
object *x;
|
object *x = NULL;
|
||||||
object * (*f) FPROTO((object *, object *));
|
object * (*f) FPROTO((object *, object *));
|
||||||
if (coerce(&v, &w) != 0)
|
if (coerce(&v, &w) != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2076,7 +2076,7 @@ xor(v, w)
|
||||||
{
|
{
|
||||||
BINOP("__xor__", "__rxor__", xor);
|
BINOP("__xor__", "__rxor__", xor);
|
||||||
if (v->ob_type->tp_as_number != NULL) {
|
if (v->ob_type->tp_as_number != NULL) {
|
||||||
object *x;
|
object *x = NULL;
|
||||||
object * (*f) FPROTO((object *, object *));
|
object * (*f) FPROTO((object *, object *));
|
||||||
if (coerce(&v, &w) != 0)
|
if (coerce(&v, &w) != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2097,7 +2097,7 @@ and(v, w)
|
||||||
{
|
{
|
||||||
BINOP("__and__", "__rand__", and);
|
BINOP("__and__", "__rand__", and);
|
||||||
if (v->ob_type->tp_as_number != NULL) {
|
if (v->ob_type->tp_as_number != NULL) {
|
||||||
object *x;
|
object *x = NULL;
|
||||||
object * (*f) FPROTO((object *, object *));
|
object * (*f) FPROTO((object *, object *));
|
||||||
if (coerce(&v, &w) != 0)
|
if (coerce(&v, &w) != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2118,7 +2118,7 @@ lshift(v, w)
|
||||||
{
|
{
|
||||||
BINOP("__lshift__", "__rlshift__", lshift);
|
BINOP("__lshift__", "__rlshift__", lshift);
|
||||||
if (v->ob_type->tp_as_number != NULL) {
|
if (v->ob_type->tp_as_number != NULL) {
|
||||||
object *x;
|
object *x = NULL;
|
||||||
object * (*f) FPROTO((object *, object *));
|
object * (*f) FPROTO((object *, object *));
|
||||||
if (coerce(&v, &w) != 0)
|
if (coerce(&v, &w) != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2139,7 +2139,7 @@ rshift(v, w)
|
||||||
{
|
{
|
||||||
BINOP("__rshift__", "__rrshift__", rshift);
|
BINOP("__rshift__", "__rrshift__", rshift);
|
||||||
if (v->ob_type->tp_as_number != NULL) {
|
if (v->ob_type->tp_as_number != NULL) {
|
||||||
object *x;
|
object *x = NULL;
|
||||||
object * (*f) FPROTO((object *, object *));
|
object * (*f) FPROTO((object *, object *));
|
||||||
if (coerce(&v, &w) != 0)
|
if (coerce(&v, &w) != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2379,7 +2379,7 @@ PyEval_CallObjectWithKeywords(func, arg, kw)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (call = func->ob_type->tp_call)
|
if ((call = func->ob_type->tp_call) != NULL)
|
||||||
result = (*call)(func, arg, kw);
|
result = (*call)(func, arg, kw);
|
||||||
else if (is_instancemethodobject(func) || is_funcobject(func))
|
else if (is_instancemethodobject(func) || is_funcobject(func))
|
||||||
result = call_function(func, arg, kw);
|
result = call_function(func, arg, kw);
|
||||||
|
@ -2890,22 +2890,6 @@ build_class(methods, bases, name)
|
||||||
err_setstr(SystemError, "build_class with non-tuple bases");
|
err_setstr(SystemError, "build_class with non-tuple bases");
|
||||||
return NULL;
|
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)) {
|
if (!is_dictobject(methods)) {
|
||||||
err_setstr(SystemError, "build_class with non-dictionary");
|
err_setstr(SystemError, "build_class with non-dictionary");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2917,6 +2901,20 @@ build_class(methods, bases, name)
|
||||||
for (i = gettuplesize(bases); --i >= 0; ) {
|
for (i = gettuplesize(bases); --i >= 0; ) {
|
||||||
object *base = GETTUPLEITEM(bases, i);
|
object *base = GETTUPLEITEM(bases, i);
|
||||||
if (!is_classobject(base)) {
|
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,
|
err_setstr(TypeError,
|
||||||
"base is not a class object");
|
"base is not a class object");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue