mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
changes for keyword args to built-in functions and classes
This commit is contained in:
parent
bebdc376c3
commit
a83f270a4b
2 changed files with 8 additions and 7 deletions
|
@ -279,9 +279,10 @@ addaccess(class, inst)
|
|||
}
|
||||
|
||||
object *
|
||||
newinstanceobject(class, arg)
|
||||
newinstanceobject(class, arg, kw)
|
||||
object *class;
|
||||
object *arg;
|
||||
object *kw;
|
||||
{
|
||||
register instanceobject *inst;
|
||||
object *init;
|
||||
|
@ -303,16 +304,16 @@ newinstanceobject(class, arg)
|
|||
init = instance_getattr1(inst, "__init__");
|
||||
if (init == NULL) {
|
||||
err_clear();
|
||||
if (arg != NULL && !(is_tupleobject(arg) &&
|
||||
gettuplesize(arg) == 0)) {
|
||||
if (arg != NULL && (!is_tupleobject(arg) ||
|
||||
gettuplesize(arg) != 0) || kw != NULL) {
|
||||
err_setstr(TypeError,
|
||||
"this classobject() takes no arguments");
|
||||
"this constructor takes no arguments");
|
||||
DECREF(inst);
|
||||
inst = NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
object *res = call_object(init, arg);
|
||||
object *res = PyEval_CallObjectWithKeywords(init, arg, kw);
|
||||
DECREF(init);
|
||||
if (res == NULL) {
|
||||
DECREF(inst);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue