@@ -3543,23 +3543,34 @@ excess_args(PyObject *args, PyObject *kwds)
35433543static int
35443544object_init (PyObject * self , PyObject * args , PyObject * kwds )
35453545{
3546- int err = 0 ;
35473546 PyTypeObject * type = Py_TYPE (self );
3548- if (excess_args (args , kwds ) &&
3549- (type -> tp_new == object_new || type -> tp_init != object_init )) {
3550- PyErr_SetString (PyExc_TypeError , "object.__init__() takes no parameters" );
3551- err = -1 ;
3547+ if (excess_args (args , kwds )) {
3548+ if (type -> tp_init != object_init ) {
3549+ PyErr_SetString (PyExc_TypeError , "object() takes no arguments" );
3550+ return -1 ;
3551+ }
3552+ if (type -> tp_new == object_new ) {
3553+ PyErr_Format (PyExc_TypeError , "%.200s() takes no arguments" ,
3554+ type -> tp_name );
3555+ return -1 ;
3556+ }
35523557 }
3553- return err ;
3558+ return 0 ;
35543559}
35553560
35563561static PyObject *
35573562object_new (PyTypeObject * type , PyObject * args , PyObject * kwds )
35583563{
3559- if (excess_args (args , kwds ) &&
3560- (type -> tp_init == object_init || type -> tp_new != object_new )) {
3561- PyErr_SetString (PyExc_TypeError , "object() takes no parameters" );
3562- return NULL ;
3564+ if (excess_args (args , kwds )) {
3565+ if (type -> tp_new != object_new ) {
3566+ PyErr_SetString (PyExc_TypeError , "object() takes no arguments" );
3567+ return NULL ;
3568+ }
3569+ if (type -> tp_init == object_init ) {
3570+ PyErr_Format (PyExc_TypeError , "%.200s() takes no arguments" ,
3571+ type -> tp_name );
3572+ return NULL ;
3573+ }
35633574 }
35643575
35653576 if (type -> tp_flags & Py_TPFLAGS_IS_ABSTRACT ) {
0 commit comments