@@ -1597,8 +1597,9 @@ static PyGetSetDef type_getsets[] = {
1597
1597
};
1598
1598
1599
1599
static PyObject *
1600
- type_repr (PyTypeObject * type )
1600
+ type_repr (PyObject * self )
1601
1601
{
1602
+ PyTypeObject * type = (PyTypeObject * )self ;
1602
1603
if (type -> tp_name == NULL ) {
1603
1604
// type_repr() called before the type is fully initialized
1604
1605
// by PyType_Ready().
@@ -1630,8 +1631,9 @@ type_repr(PyTypeObject *type)
1630
1631
}
1631
1632
1632
1633
static PyObject *
1633
- type_call (PyTypeObject * type , PyObject * args , PyObject * kwds )
1634
+ type_call (PyObject * self , PyObject * args , PyObject * kwds )
1634
1635
{
1636
+ PyTypeObject * type = (PyTypeObject * )self ;
1635
1637
PyObject * obj ;
1636
1638
PyThreadState * tstate = _PyThreadState_GET ();
1637
1639
@@ -4917,14 +4919,15 @@ _Py_type_getattro_impl(PyTypeObject *type, PyObject *name, int * suppress_missin
4917
4919
/* This is similar to PyObject_GenericGetAttr(),
4918
4920
but uses _PyType_Lookup() instead of just looking in type->tp_dict. */
4919
4921
PyObject *
4920
- _Py_type_getattro (PyTypeObject * type , PyObject * name )
4922
+ _Py_type_getattro (PyObject * type , PyObject * name )
4921
4923
{
4922
- return _Py_type_getattro_impl (type , name , NULL );
4924
+ return _Py_type_getattro_impl (( PyTypeObject * ) type , name , NULL );
4923
4925
}
4924
4926
4925
4927
static int
4926
- type_setattro (PyTypeObject * type , PyObject * name , PyObject * value )
4928
+ type_setattro (PyObject * self , PyObject * name , PyObject * value )
4927
4929
{
4930
+ PyTypeObject * type = (PyTypeObject * )self ;
4928
4931
int res ;
4929
4932
if (type -> tp_flags & Py_TPFLAGS_IMMUTABLETYPE ) {
4930
4933
PyErr_Format (
@@ -5069,8 +5072,10 @@ _PyStaticType_Dealloc(PyInterpreterState *interp, PyTypeObject *type)
5069
5072
5070
5073
5071
5074
static void
5072
- type_dealloc (PyTypeObject * type )
5075
+ type_dealloc (PyObject * self )
5073
5076
{
5077
+ PyTypeObject * type = (PyTypeObject * )self ;
5078
+
5074
5079
// Assert this is a heap-allocated type object
5075
5080
_PyObject_ASSERT ((PyObject * )type , type -> tp_flags & Py_TPFLAGS_HEAPTYPE );
5076
5081
@@ -5257,8 +5262,10 @@ PyDoc_STRVAR(type_doc,
5257
5262
"type(name, bases, dict, **kwds) -> a new type" );
5258
5263
5259
5264
static int
5260
- type_traverse (PyTypeObject * type , visitproc visit , void * arg )
5265
+ type_traverse (PyObject * self , visitproc visit , void * arg )
5261
5266
{
5267
+ PyTypeObject * type = (PyTypeObject * )self ;
5268
+
5262
5269
/* Because of type_is_gc(), the collector only calls this
5263
5270
for heaptypes. */
5264
5271
if (!(type -> tp_flags & Py_TPFLAGS_HEAPTYPE )) {
@@ -5286,8 +5293,10 @@ type_traverse(PyTypeObject *type, visitproc visit, void *arg)
5286
5293
}
5287
5294
5288
5295
static int
5289
- type_clear (PyTypeObject * type )
5296
+ type_clear (PyObject * self )
5290
5297
{
5298
+ PyTypeObject * type = (PyTypeObject * )self ;
5299
+
5291
5300
/* Because of type_is_gc(), the collector only calls this
5292
5301
for heaptypes. */
5293
5302
_PyObject_ASSERT ((PyObject * )type , type -> tp_flags & Py_TPFLAGS_HEAPTYPE );
@@ -5334,9 +5343,9 @@ type_clear(PyTypeObject *type)
5334
5343
}
5335
5344
5336
5345
static int
5337
- type_is_gc (PyTypeObject * type )
5346
+ type_is_gc (PyObject * type )
5338
5347
{
5339
- return type -> tp_flags & Py_TPFLAGS_HEAPTYPE ;
5348
+ return (( PyTypeObject * ) type ) -> tp_flags & Py_TPFLAGS_HEAPTYPE ;
5340
5349
}
5341
5350
5342
5351
@@ -5349,28 +5358,28 @@ PyTypeObject PyType_Type = {
5349
5358
"type" , /* tp_name */
5350
5359
sizeof (PyHeapTypeObject ), /* tp_basicsize */
5351
5360
sizeof (PyMemberDef ), /* tp_itemsize */
5352
- ( destructor ) type_dealloc , /* tp_dealloc */
5361
+ type_dealloc , /* tp_dealloc */
5353
5362
offsetof(PyTypeObject , tp_vectorcall ), /* tp_vectorcall_offset */
5354
5363
0 , /* tp_getattr */
5355
5364
0 , /* tp_setattr */
5356
5365
0 , /* tp_as_async */
5357
- ( reprfunc ) type_repr , /* tp_repr */
5366
+ type_repr , /* tp_repr */
5358
5367
& type_as_number , /* tp_as_number */
5359
5368
0 , /* tp_as_sequence */
5360
5369
0 , /* tp_as_mapping */
5361
5370
0 , /* tp_hash */
5362
- ( ternaryfunc ) type_call , /* tp_call */
5371
+ type_call , /* tp_call */
5363
5372
0 , /* tp_str */
5364
- ( getattrofunc ) _Py_type_getattro , /* tp_getattro */
5365
- ( setattrofunc ) type_setattro , /* tp_setattro */
5373
+ _Py_type_getattro , /* tp_getattro */
5374
+ type_setattro , /* tp_setattro */
5366
5375
0 , /* tp_as_buffer */
5367
5376
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
5368
5377
Py_TPFLAGS_BASETYPE | Py_TPFLAGS_TYPE_SUBCLASS |
5369
5378
Py_TPFLAGS_HAVE_VECTORCALL |
5370
5379
Py_TPFLAGS_ITEMS_AT_END , /* tp_flags */
5371
5380
type_doc , /* tp_doc */
5372
- ( traverseproc ) type_traverse , /* tp_traverse */
5373
- ( inquiry ) type_clear , /* tp_clear */
5381
+ type_traverse , /* tp_traverse */
5382
+ type_clear , /* tp_clear */
5374
5383
0 , /* tp_richcompare */
5375
5384
offsetof(PyTypeObject , tp_weaklist ), /* tp_weaklistoffset */
5376
5385
0 , /* tp_iter */
@@ -5387,7 +5396,7 @@ PyTypeObject PyType_Type = {
5387
5396
0 , /* tp_alloc */
5388
5397
type_new , /* tp_new */
5389
5398
PyObject_GC_Del , /* tp_free */
5390
- ( inquiry ) type_is_gc , /* tp_is_gc */
5399
+ type_is_gc , /* tp_is_gc */
5391
5400
.tp_vectorcall = type_vectorcall ,
5392
5401
};
5393
5402
@@ -6561,6 +6570,12 @@ PyDoc_STRVAR(object_doc,
6561
6570
"When called, it accepts no arguments and returns a new featureless\n"
6562
6571
"instance that has no instance attributes and cannot be given any.\n" );
6563
6572
6573
+ static Py_hash_t
6574
+ object_hash (PyObject * obj )
6575
+ {
6576
+ return _Py_HashPointer (obj );
6577
+ }
6578
+
6564
6579
PyTypeObject PyBaseObject_Type = {
6565
6580
PyVarObject_HEAD_INIT (& PyType_Type , 0 )
6566
6581
"object" , /* tp_name */
@@ -6575,7 +6590,7 @@ PyTypeObject PyBaseObject_Type = {
6575
6590
0 , /* tp_as_number */
6576
6591
0 , /* tp_as_sequence */
6577
6592
0 , /* tp_as_mapping */
6578
- ( hashfunc ) _Py_HashPointer , /* tp_hash */
6593
+ object_hash , /* tp_hash */
6579
6594
0 , /* tp_call */
6580
6595
object_str , /* tp_str */
6581
6596
PyObject_GenericGetAttr , /* tp_getattro */
0 commit comments