Kaydet (Commit) a83f270a authored tarafından Guido van Rossum's avatar Guido van Rossum

changes for keyword args to built-in functions and classes

üst bebdc376
...@@ -279,9 +279,10 @@ addaccess(class, inst) ...@@ -279,9 +279,10 @@ addaccess(class, inst)
} }
object * object *
newinstanceobject(class, arg) newinstanceobject(class, arg, kw)
object *class; object *class;
object *arg; object *arg;
object *kw;
{ {
register instanceobject *inst; register instanceobject *inst;
object *init; object *init;
...@@ -303,16 +304,16 @@ newinstanceobject(class, arg) ...@@ -303,16 +304,16 @@ newinstanceobject(class, arg)
init = instance_getattr1(inst, "__init__"); init = instance_getattr1(inst, "__init__");
if (init == NULL) { if (init == NULL) {
err_clear(); err_clear();
if (arg != NULL && !(is_tupleobject(arg) && if (arg != NULL && (!is_tupleobject(arg) ||
gettuplesize(arg) == 0)) { gettuplesize(arg) != 0) || kw != NULL) {
err_setstr(TypeError, err_setstr(TypeError,
"this classobject() takes no arguments"); "this constructor takes no arguments");
DECREF(inst); DECREF(inst);
inst = NULL; inst = NULL;
} }
} }
else { else {
object *res = call_object(init, arg); object *res = PyEval_CallObjectWithKeywords(init, arg, kw);
DECREF(init); DECREF(init);
if (res == NULL) { if (res == NULL) {
DECREF(inst); DECREF(inst);
......
...@@ -71,14 +71,14 @@ getself(op) ...@@ -71,14 +71,14 @@ getself(op)
} }
int int
getvarargs(op) getflags(op)
object *op; object *op;
{ {
if (!is_methodobject(op)) { if (!is_methodobject(op)) {
err_badcall(); err_badcall();
return -1; return -1;
} }
return ((methodobject *)op) -> m_ml -> ml_flags & METH_VARARGS; return ((methodobject *)op) -> m_ml -> ml_flags;
} }
/* Methods (the standard built-in methods, that is) */ /* Methods (the standard built-in methods, that is) */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment