@@ -269,7 +269,7 @@ PyType_Modified(PyTypeObject *type)
269
269
PyObject * raw , * ref ;
270
270
Py_ssize_t i ;
271
271
272
- if (!PyType_HasFeature (type , Py_TPFLAGS_VALID_VERSION_TAG ))
272
+ if (!_PyType_HasFeature (type , Py_TPFLAGS_VALID_VERSION_TAG ))
273
273
return ;
274
274
275
275
raw = type -> tp_subclasses ;
@@ -307,7 +307,7 @@ type_mro_modified(PyTypeObject *type, PyObject *bases) {
307
307
PyObject * mro_meth = NULL ;
308
308
PyObject * type_mro_meth = NULL ;
309
309
310
- if (!PyType_HasFeature (type , Py_TPFLAGS_HAVE_VERSION_TAG ))
310
+ if (!_PyType_HasFeature (type , Py_TPFLAGS_HAVE_VERSION_TAG ))
311
311
return ;
312
312
313
313
if (custom ) {
@@ -332,7 +332,7 @@ type_mro_modified(PyTypeObject *type, PyObject *bases) {
332
332
assert (PyType_Check (b ));
333
333
cls = (PyTypeObject * )b ;
334
334
335
- if (!PyType_HasFeature (cls , Py_TPFLAGS_HAVE_VERSION_TAG ) ||
335
+ if (!_PyType_HasFeature (cls , Py_TPFLAGS_HAVE_VERSION_TAG ) ||
336
336
!PyType_IsSubtype (type , cls )) {
337
337
goto clear ;
338
338
}
@@ -356,11 +356,11 @@ assign_version_tag(PyTypeObject *type)
356
356
Py_ssize_t i , n ;
357
357
PyObject * bases ;
358
358
359
- if (PyType_HasFeature (type , Py_TPFLAGS_VALID_VERSION_TAG ))
359
+ if (_PyType_HasFeature (type , Py_TPFLAGS_VALID_VERSION_TAG ))
360
360
return 1 ;
361
- if (!PyType_HasFeature (type , Py_TPFLAGS_HAVE_VERSION_TAG ))
361
+ if (!_PyType_HasFeature (type , Py_TPFLAGS_HAVE_VERSION_TAG ))
362
362
return 0 ;
363
- if (!PyType_HasFeature (type , Py_TPFLAGS_READY ))
363
+ if (!_PyType_HasFeature (type , Py_TPFLAGS_READY ))
364
364
return 0 ;
365
365
366
366
type -> tp_version_tag = next_version_tag ++ ;
@@ -1028,23 +1028,29 @@ PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
1028
1028
const size_t size = _PyObject_VAR_SIZE (type , nitems + 1 );
1029
1029
/* note that we need to add one, for the sentinel */
1030
1030
1031
- if (PyType_IS_GC (type ))
1031
+ if (_PyType_IS_GC (type )) {
1032
1032
obj = _PyObject_GC_Malloc (size );
1033
- else
1033
+ }
1034
+ else {
1034
1035
obj = (PyObject * )PyObject_MALLOC (size );
1036
+ }
1035
1037
1036
- if (obj == NULL )
1038
+ if (obj == NULL ) {
1037
1039
return PyErr_NoMemory ();
1040
+ }
1038
1041
1039
1042
memset (obj , '\0' , size );
1040
1043
1041
- if (type -> tp_itemsize == 0 )
1044
+ if (type -> tp_itemsize == 0 ) {
1042
1045
(void )PyObject_INIT (obj , type );
1043
- else
1046
+ }
1047
+ else {
1044
1048
(void ) PyObject_INIT_VAR ((PyVarObject * )obj , type , nitems );
1049
+ }
1045
1050
1046
- if (PyType_IS_GC (type ))
1051
+ if (_PyType_IS_GC (type )) {
1047
1052
_PyObject_GC_TRACK (obj );
1053
+ }
1048
1054
return obj ;
1049
1055
}
1050
1056
@@ -1178,7 +1184,7 @@ subtype_dealloc(PyObject *self)
1178
1184
1179
1185
/* Test whether the type has GC exactly once */
1180
1186
1181
- if (!PyType_IS_GC (type )) {
1187
+ if (!_PyType_IS_GC (type )) {
1182
1188
/* A non GC dynamic type allows certain simplifications:
1183
1189
there's no need to call clear_slots(), or DECREF the dict,
1184
1190
or clear weakrefs. */
@@ -1304,8 +1310,9 @@ subtype_dealloc(PyObject *self)
1304
1310
/* Call the base tp_dealloc(); first retrack self if
1305
1311
* basedealloc knows about gc.
1306
1312
*/
1307
- if (PyType_IS_GC (base ))
1313
+ if (_PyType_IS_GC (base )) {
1308
1314
_PyObject_GC_TRACK (self );
1315
+ }
1309
1316
assert (basedealloc );
1310
1317
basedealloc (self );
1311
1318
@@ -1435,7 +1442,7 @@ lookup_maybe_method(PyObject *self, _Py_Identifier *attrid, int *unbound)
1435
1442
return NULL ;
1436
1443
}
1437
1444
1438
- if (PyType_HasFeature (Py_TYPE (res ), Py_TPFLAGS_METHOD_DESCRIPTOR )) {
1445
+ if (_PyType_HasFeature (Py_TYPE (res ), Py_TPFLAGS_METHOD_DESCRIPTOR )) {
1439
1446
/* Avoid temporary PyMethodObject */
1440
1447
* unbound = 1 ;
1441
1448
Py_INCREF (res );
@@ -2026,7 +2033,7 @@ best_base(PyObject *bases)
2026
2033
if (PyType_Ready (base_i ) < 0 )
2027
2034
return NULL ;
2028
2035
}
2029
- if (!PyType_HasFeature (base_i , Py_TPFLAGS_BASETYPE )) {
2036
+ if (!_PyType_HasFeature (base_i , Py_TPFLAGS_BASETYPE )) {
2030
2037
PyErr_Format (PyExc_TypeError ,
2031
2038
"type '%.100s' is not an acceptable base type" ,
2032
2039
base_i -> tp_name );
@@ -2933,7 +2940,7 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
2933
2940
if (base == NULL ) {
2934
2941
goto fail ;
2935
2942
}
2936
- if (!PyType_HasFeature (base , Py_TPFLAGS_BASETYPE )) {
2943
+ if (!_PyType_HasFeature (base , Py_TPFLAGS_BASETYPE )) {
2937
2944
PyErr_Format (PyExc_TypeError ,
2938
2945
"type '%.100s' is not an acceptable base type" ,
2939
2946
base -> tp_name );
@@ -3051,7 +3058,7 @@ PyType_FromSpec(PyType_Spec *spec)
3051
3058
void *
3052
3059
PyType_GetSlot (PyTypeObject * type , int slot )
3053
3060
{
3054
- if (!PyType_HasFeature (type , Py_TPFLAGS_HEAPTYPE ) || slot < 0 ) {
3061
+ if (!_PyType_HasFeature (type , Py_TPFLAGS_HEAPTYPE ) || slot < 0 ) {
3055
3062
PyErr_BadInternalCall ();
3056
3063
return NULL ;
3057
3064
}
@@ -3134,7 +3141,7 @@ _PyType_Lookup(PyTypeObject *type, PyObject *name)
3134
3141
unsigned int h ;
3135
3142
3136
3143
if (MCACHE_CACHEABLE_NAME (name ) &&
3137
- PyType_HasFeature (type , Py_TPFLAGS_VALID_VERSION_TAG )) {
3144
+ _PyType_HasFeature (type , Py_TPFLAGS_VALID_VERSION_TAG )) {
3138
3145
/* fast path */
3139
3146
h = MCACHE_HASH_METHOD (type , name );
3140
3147
if (method_cache [h ].version == type -> tp_version_tag &&
@@ -5404,7 +5411,7 @@ PyType_Ready(PyTypeObject *type)
5404
5411
}
5405
5412
5406
5413
/* Sanity check for tp_free. */
5407
- if (PyType_IS_GC (type ) && (type -> tp_flags & Py_TPFLAGS_BASETYPE ) &&
5414
+ if (_PyType_IS_GC (type ) && (type -> tp_flags & Py_TPFLAGS_BASETYPE ) &&
5408
5415
(type -> tp_free == NULL || type -> tp_free == PyObject_Del )) {
5409
5416
/* This base class needs to call tp_free, but doesn't have
5410
5417
* one, or its tp_free is for non-gc'ed objects.
0 commit comments