mirror of
https://github.com/python/cpython.git
synced 2025-07-10 04:45:36 +00:00
Added "apply"; added "SyntaxError"; changed table lay-out.
This commit is contained in:
parent
d39e412482
commit
c02e15c45e
1 changed files with 42 additions and 23 deletions
|
@ -53,6 +53,21 @@ builtin_abs(self, v)
|
||||||
return (*nm->nb_absolute)(v);
|
return (*nm->nb_absolute)(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static object *
|
||||||
|
builtin_apply(self, v)
|
||||||
|
object *self;
|
||||||
|
object *v;
|
||||||
|
{
|
||||||
|
object *func, *args;
|
||||||
|
if (v == NULL || !is_tupleobject(v) || gettuplesize(v) != 2) {
|
||||||
|
err_setstr(TypeError, "apply() requires (func,args)");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
func = gettupleitem(v, 0);
|
||||||
|
args = gettupleitem(v, 1);
|
||||||
|
return call_object(func, args);
|
||||||
|
}
|
||||||
|
|
||||||
static object *
|
static object *
|
||||||
builtin_chr(self, v)
|
builtin_chr(self, v)
|
||||||
object *self;
|
object *self;
|
||||||
|
@ -550,29 +565,30 @@ builtin_type(self, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct methodlist builtin_methods[] = {
|
static struct methodlist builtin_methods[] = {
|
||||||
{"abs", builtin_abs},
|
{"abs", builtin_abs},
|
||||||
{"chr", builtin_chr},
|
{"apply", builtin_apply},
|
||||||
{"dir", builtin_dir},
|
{"chr", builtin_chr},
|
||||||
{"divmod", builtin_divmod},
|
{"dir", builtin_dir},
|
||||||
{"eval", builtin_eval},
|
{"divmod", builtin_divmod},
|
||||||
{"exec", builtin_exec},
|
{"eval", builtin_eval},
|
||||||
{"float", builtin_float},
|
{"exec", builtin_exec},
|
||||||
{"hex", builtin_hex},
|
{"float", builtin_float},
|
||||||
{"input", builtin_input},
|
{"hex", builtin_hex},
|
||||||
{"int", builtin_int},
|
{"input", builtin_input},
|
||||||
{"len", builtin_len},
|
{"int", builtin_int},
|
||||||
{"long", builtin_long},
|
{"len", builtin_len},
|
||||||
{"max", builtin_max},
|
{"long", builtin_long},
|
||||||
{"min", builtin_min},
|
{"max", builtin_max},
|
||||||
{"oct", builtin_oct},
|
{"min", builtin_min},
|
||||||
{"open", builtin_open}, /* XXX move to OS module */
|
{"oct", builtin_oct},
|
||||||
{"ord", builtin_ord},
|
{"open", builtin_open}, /* XXX move to OS module */
|
||||||
{"pow", builtin_pow},
|
{"ord", builtin_ord},
|
||||||
{"range", builtin_range},
|
{"pow", builtin_pow},
|
||||||
{"raw_input", builtin_raw_input},
|
{"range", builtin_range},
|
||||||
{"reload", builtin_reload},
|
{"raw_input", builtin_raw_input},
|
||||||
{"type", builtin_type},
|
{"reload", builtin_reload},
|
||||||
{NULL, NULL},
|
{"type", builtin_type},
|
||||||
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
static object *builtin_dict;
|
static object *builtin_dict;
|
||||||
|
@ -602,6 +618,7 @@ object *IndexError;
|
||||||
object *ValueError;
|
object *ValueError;
|
||||||
object *KeyError;
|
object *KeyError;
|
||||||
object *OverflowError;
|
object *OverflowError;
|
||||||
|
object *SyntaxError;
|
||||||
|
|
||||||
static object *
|
static object *
|
||||||
newstdexception(name, message)
|
newstdexception(name, message)
|
||||||
|
@ -636,6 +653,8 @@ initerrors()
|
||||||
KeyError = newstdexception("KeyError", "invalid key");
|
KeyError = newstdexception("KeyError", "invalid key");
|
||||||
OverflowError =
|
OverflowError =
|
||||||
newstdexception("OverflowError", "arithmetic overflow");
|
newstdexception("OverflowError", "arithmetic overflow");
|
||||||
|
SyntaxError =
|
||||||
|
newstdexception("SyntaxError", "syntax error");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue