@@ -58,7 +58,7 @@ _Py_GetRefTotal(void)
58
58
Py_ssize_t total = _Py_RefTotal ;
59
59
o = _PySet_Dummy ;
60
60
if (o != NULL )
61
- total -= o -> ob_refcnt ;
61
+ total -= Py_REFCNT ( o ) ;
62
62
return total ;
63
63
}
64
64
@@ -206,32 +206,32 @@ PyObject_CallFinalizer(PyObject *self)
206
206
int
207
207
PyObject_CallFinalizerFromDealloc (PyObject * self )
208
208
{
209
- if (self -> ob_refcnt != 0 ) {
209
+ if (Py_REFCNT ( self ) != 0 ) {
210
210
_PyObject_ASSERT_FAILED_MSG (self ,
211
211
"PyObject_CallFinalizerFromDealloc called "
212
212
"on object with a non-zero refcount" );
213
213
}
214
214
215
215
/* Temporarily resurrect the object. */
216
- self -> ob_refcnt = 1 ;
216
+ Py_REFCNT ( self ) = 1 ;
217
217
218
218
PyObject_CallFinalizer (self );
219
219
220
220
_PyObject_ASSERT_WITH_MSG (self ,
221
- self -> ob_refcnt > 0 ,
221
+ Py_REFCNT ( self ) > 0 ,
222
222
"refcount is too small" );
223
223
224
224
/* Undo the temporary resurrection; can't use DECREF here, it would
225
225
* cause a recursive call. */
226
- if (-- self -> ob_refcnt == 0 ) {
226
+ if (-- Py_REFCNT ( self ) == 0 ) {
227
227
return 0 ; /* this is the normal path out */
228
228
}
229
229
230
230
/* tp_finalize resurrected it! Make it look like the original Py_DECREF
231
231
* never happened. */
232
- Py_ssize_t refcnt = self -> ob_refcnt ;
232
+ Py_ssize_t refcnt = Py_REFCNT ( self ) ;
233
233
_Py_NewReference (self );
234
- self -> ob_refcnt = refcnt ;
234
+ Py_REFCNT ( self ) = refcnt ;
235
235
236
236
_PyObject_ASSERT (self ,
237
237
(!PyType_IS_GC (Py_TYPE (self ))
@@ -263,12 +263,12 @@ PyObject_Print(PyObject *op, FILE *fp, int flags)
263
263
Py_END_ALLOW_THREADS
264
264
}
265
265
else {
266
- if (op -> ob_refcnt <= 0 ) {
266
+ if (Py_REFCNT ( op ) <= 0 ) {
267
267
/* XXX(twouters) cast refcount to long until %zd is
268
268
universally available */
269
269
Py_BEGIN_ALLOW_THREADS
270
270
fprintf (fp , "<refcnt %ld at %p>" ,
271
- (long )op -> ob_refcnt , (void * )op );
271
+ (long )Py_REFCNT ( op ) , (void * )op );
272
272
Py_END_ALLOW_THREADS
273
273
}
274
274
else {
@@ -363,7 +363,7 @@ _PyObject_Dump(PyObject* op)
363
363
fprintf (stderr , "object address : %p\n" , (void * )op );
364
364
/* XXX(twouters) cast refcount to long until %zd is
365
365
universally available */
366
- fprintf (stderr , "object refcount : %ld\n" , (long )op -> ob_refcnt );
366
+ fprintf (stderr , "object refcount : %ld\n" , (long )Py_REFCNT ( op ) );
367
367
fflush (stderr );
368
368
369
369
PyTypeObject * type = Py_TYPE (op );
@@ -1010,7 +1010,7 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
1010
1010
return err ;
1011
1011
}
1012
1012
Py_DECREF (name );
1013
- _PyObject_ASSERT (name , name -> ob_refcnt >= 1 );
1013
+ _PyObject_ASSERT (name , Py_REFCNT ( name ) >= 1 );
1014
1014
if (tp -> tp_getattr == NULL && tp -> tp_getattro == NULL )
1015
1015
PyErr_Format (PyExc_TypeError ,
1016
1016
"'%.100s' object has no attributes "
@@ -1829,7 +1829,7 @@ _Py_NewReference(PyObject *op)
1829
1829
void
1830
1830
_Py_ForgetReference (PyObject * op )
1831
1831
{
1832
- if (op -> ob_refcnt < 0 ) {
1832
+ if (Py_REFCNT ( op ) < 0 ) {
1833
1833
_PyObject_ASSERT_FAILED_MSG (op , "negative refcnt" );
1834
1834
}
1835
1835
@@ -1867,7 +1867,7 @@ _Py_PrintReferences(FILE *fp)
1867
1867
PyObject * op ;
1868
1868
fprintf (fp , "Remaining objects:\n" );
1869
1869
for (op = refchain ._ob_next ; op != & refchain ; op = op -> _ob_next ) {
1870
- fprintf (fp , "%p [%" PY_FORMAT_SIZE_T "d] " , (void * )op , op -> ob_refcnt );
1870
+ fprintf (fp , "%p [%" PY_FORMAT_SIZE_T "d] " , (void * )op , Py_REFCNT ( op ) );
1871
1871
if (PyObject_Print (op , fp , 0 ) != 0 )
1872
1872
PyErr_Clear ();
1873
1873
putc ('\n' , fp );
@@ -1884,7 +1884,7 @@ _Py_PrintReferenceAddresses(FILE *fp)
1884
1884
fprintf (fp , "Remaining object addresses:\n" );
1885
1885
for (op = refchain ._ob_next ; op != & refchain ; op = op -> _ob_next )
1886
1886
fprintf (fp , "%p [%" PY_FORMAT_SIZE_T "d] %s\n" , (void * )op ,
1887
- op -> ob_refcnt , Py_TYPE (op )-> tp_name );
1887
+ Py_REFCNT ( op ) , Py_TYPE (op )-> tp_name );
1888
1888
}
1889
1889
1890
1890
PyObject *
@@ -2025,7 +2025,7 @@ _PyTrash_deposit_object(PyObject *op)
2025
2025
2026
2026
_PyObject_ASSERT (op , PyObject_IS_GC (op ));
2027
2027
_PyObject_ASSERT (op , !_PyObject_GC_IS_TRACKED (op ));
2028
- _PyObject_ASSERT (op , op -> ob_refcnt == 0 );
2028
+ _PyObject_ASSERT (op , Py_REFCNT ( op ) == 0 );
2029
2029
_PyGCHead_SET_PREV (_Py_AS_GC (op ), gcstate -> trash_delete_later );
2030
2030
gcstate -> trash_delete_later = op ;
2031
2031
}
@@ -2037,7 +2037,7 @@ _PyTrash_thread_deposit_object(PyObject *op)
2037
2037
PyThreadState * tstate = _PyThreadState_GET ();
2038
2038
_PyObject_ASSERT (op , PyObject_IS_GC (op ));
2039
2039
_PyObject_ASSERT (op , !_PyObject_GC_IS_TRACKED (op ));
2040
- _PyObject_ASSERT (op , op -> ob_refcnt == 0 );
2040
+ _PyObject_ASSERT (op , Py_REFCNT ( op ) == 0 );
2041
2041
_PyGCHead_SET_PREV (_Py_AS_GC (op ), tstate -> trash_delete_later );
2042
2042
tstate -> trash_delete_later = op ;
2043
2043
}
@@ -2064,7 +2064,7 @@ _PyTrash_destroy_chain(void)
2064
2064
* assorted non-release builds calling Py_DECREF again ends
2065
2065
* up distorting allocation statistics.
2066
2066
*/
2067
- _PyObject_ASSERT (op , op -> ob_refcnt == 0 );
2067
+ _PyObject_ASSERT (op , Py_REFCNT ( op ) == 0 );
2068
2068
++ gcstate -> trash_delete_nesting ;
2069
2069
(* dealloc )(op );
2070
2070
-- gcstate -> trash_delete_nesting ;
@@ -2102,7 +2102,7 @@ _PyTrash_thread_destroy_chain(void)
2102
2102
* assorted non-release builds calling Py_DECREF again ends
2103
2103
* up distorting allocation statistics.
2104
2104
*/
2105
- _PyObject_ASSERT (op , op -> ob_refcnt == 0 );
2105
+ _PyObject_ASSERT (op , Py_REFCNT ( op ) == 0 );
2106
2106
(* dealloc )(op );
2107
2107
assert (tstate -> trash_delete_nesting == 1 );
2108
2108
}
0 commit comments