summaryrefslogtreecommitdiffstats
path: root/Objects/typeobject.c
diff options
context:
space:
mode:
authorSergey Fedoseev <fedoseev.sergey@gmail.com>2021-06-16 13:04:38 (GMT)
committerGitHub <noreply@github.com>2021-06-16 13:04:38 (GMT)
commitab030d6f9d73e7f6c2213c2e308d1ceb04761485 (patch)
tree37706f246f845cb66f88b40cd0f6c0b50263a08d /Objects/typeobject.c
parent0729694246174a5c2f0ae197f2e0dbea61b90c9f (diff)
downloadcpython-ab030d6f9d73e7f6c2213c2e308d1ceb04761485.zip
cpython-ab030d6f9d73e7f6c2213c2e308d1ceb04761485.tar.gz
cpython-ab030d6f9d73e7f6c2213c2e308d1ceb04761485.tar.bz2
bpo-38211: Clean up type_init() (GH-16257)
1. Remove conditions already checked by assert() 2. Remove object_init() call that effectively creates an empty tuple and checks that this tuple is empty
Diffstat (limited to 'Objects/typeobject.c')
-rw-r--r--Objects/typeobject.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 170929f..fbe3d16 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2428,41 +2428,26 @@ valid_identifier(PyObject *s)
return 1;
}
-/* Forward */
-static int
-object_init(PyObject *self, PyObject *args, PyObject *kwds);
-
static int
type_init(PyObject *cls, PyObject *args, PyObject *kwds)
{
- int res;
-
assert(args != NULL && PyTuple_Check(args));
assert(kwds == NULL || PyDict_Check(kwds));
- if (kwds != NULL && PyTuple_Check(args) && PyTuple_GET_SIZE(args) == 1 &&
- PyDict_Check(kwds) && PyDict_GET_SIZE(kwds) != 0) {
+ if (kwds != NULL && PyTuple_GET_SIZE(args) == 1 &&
+ PyDict_GET_SIZE(kwds) != 0) {
PyErr_SetString(PyExc_TypeError,
"type.__init__() takes no keyword arguments");
return -1;
}
- if (args != NULL && PyTuple_Check(args) &&
- (PyTuple_GET_SIZE(args) != 1 && PyTuple_GET_SIZE(args) != 3)) {
+ if ((PyTuple_GET_SIZE(args) != 1 && PyTuple_GET_SIZE(args) != 3)) {
PyErr_SetString(PyExc_TypeError,
"type.__init__() takes 1 or 3 arguments");
return -1;
}
- /* Call object.__init__(self) now. */
- /* XXX Could call super(type, cls).__init__() but what's the point? */
- args = PyTuple_GetSlice(args, 0, 0);
- if (args == NULL) {
- return -1;
- }
- res = object_init(cls, args, NULL);
- Py_DECREF(args);
- return res;
+ return 0;
}
unsigned long