Catch extraneous kwargs in __new__ with default __init__

This commit is contained in:
K. Lange 2023-06-13 17:36:04 +09:00
parent 011a33ff43
commit 85319d7f27

View File

@ -203,7 +203,7 @@ KRK_StaticMethod(object,__new__) {
_cls = _cls->base;
}
if (_argc && _class->_init == vm.baseClasses->objectClass->_init) {
if (_class->_init == vm.baseClasses->objectClass->_init && (_argc || (hasKw && AS_DICT(argv[argc])->count))) {
return krk_runtimeError(vm.exceptions->typeError, "%S() takes no arguments", _class->name);
}