@@ -58,7 +58,7 @@ _Py_GetRefTotal(void)
5858 Py_ssize_t total = _Py_RefTotal ;
5959 o = _PySet_Dummy ;
6060 if (o != NULL )
61- total -= o -> ob_refcnt ;
61+ total -= Py_REFCNT ( o ) ;
6262 return total ;
6363}
6464
@@ -206,32 +206,32 @@ PyObject_CallFinalizer(PyObject *self)
206206int
207207PyObject_CallFinalizerFromDealloc (PyObject * self )
208208{
209- if (self -> ob_refcnt != 0 ) {
209+ if (Py_REFCNT ( self ) != 0 ) {
210210 _PyObject_ASSERT_FAILED_MSG (self ,
211211 "PyObject_CallFinalizerFromDealloc called "
212212 "on object with a non-zero refcount" );
213213 }
214214
215215 /* Temporarily resurrect the object. */
216- self -> ob_refcnt = 1 ;
216+ Py_REFCNT ( self ) = 1 ;
217217
218218 PyObject_CallFinalizer (self );
219219
220220 _PyObject_ASSERT_WITH_MSG (self ,
221- self -> ob_refcnt > 0 ,
221+ Py_REFCNT ( self ) > 0 ,
222222 "refcount is too small" );
223223
224224 /* Undo the temporary resurrection; can't use DECREF here, it would
225225 * cause a recursive call. */
226- if (-- self -> ob_refcnt == 0 ) {
226+ if (-- Py_REFCNT ( self ) == 0 ) {
227227 return 0 ; /* this is the normal path out */
228228 }
229229
230230 /* tp_finalize resurrected it! Make it look like the original Py_DECREF
231231 * never happened. */
232- Py_ssize_t refcnt = self -> ob_refcnt ;
232+ Py_ssize_t refcnt = Py_REFCNT ( self ) ;
233233 _Py_NewReference (self );
234- self -> ob_refcnt = refcnt ;
234+ Py_REFCNT ( self ) = refcnt ;
235235
236236 _PyObject_ASSERT (self ,
237237 (!PyType_IS_GC (Py_TYPE (self ))
@@ -263,12 +263,12 @@ PyObject_Print(PyObject *op, FILE *fp, int flags)
263263 Py_END_ALLOW_THREADS
264264 }
265265 else {
266- if (op -> ob_refcnt <= 0 ) {
266+ if (Py_REFCNT ( op ) <= 0 ) {
267267 /* XXX(twouters) cast refcount to long until %zd is
268268 universally available */
269269 Py_BEGIN_ALLOW_THREADS
270270 fprintf (fp , "<refcnt %ld at %p>" ,
271- (long )op -> ob_refcnt , (void * )op );
271+ (long )Py_REFCNT ( op ) , (void * )op );
272272 Py_END_ALLOW_THREADS
273273 }
274274 else {
@@ -363,7 +363,7 @@ _PyObject_Dump(PyObject* op)
363363 fprintf (stderr , "object address : %p\n" , (void * )op );
364364 /* XXX(twouters) cast refcount to long until %zd is
365365 universally available */
366- fprintf (stderr , "object refcount : %ld\n" , (long )op -> ob_refcnt );
366+ fprintf (stderr , "object refcount : %ld\n" , (long )Py_REFCNT ( op ) );
367367 fflush (stderr );
368368
369369 PyTypeObject * type = Py_TYPE (op );
@@ -1010,7 +1010,7 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
10101010 return err ;
10111011 }
10121012 Py_DECREF (name );
1013- _PyObject_ASSERT (name , name -> ob_refcnt >= 1 );
1013+ _PyObject_ASSERT (name , Py_REFCNT ( name ) >= 1 );
10141014 if (tp -> tp_getattr == NULL && tp -> tp_getattro == NULL )
10151015 PyErr_Format (PyExc_TypeError ,
10161016 "'%.100s' object has no attributes "
@@ -1829,7 +1829,7 @@ _Py_NewReference(PyObject *op)
18291829void
18301830_Py_ForgetReference (PyObject * op )
18311831{
1832- if (op -> ob_refcnt < 0 ) {
1832+ if (Py_REFCNT ( op ) < 0 ) {
18331833 _PyObject_ASSERT_FAILED_MSG (op , "negative refcnt" );
18341834 }
18351835
@@ -1867,7 +1867,7 @@ _Py_PrintReferences(FILE *fp)
18671867 PyObject * op ;
18681868 fprintf (fp , "Remaining objects:\n" );
18691869 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 ) );
18711871 if (PyObject_Print (op , fp , 0 ) != 0 )
18721872 PyErr_Clear ();
18731873 putc ('\n' , fp );
@@ -1884,7 +1884,7 @@ _Py_PrintReferenceAddresses(FILE *fp)
18841884 fprintf (fp , "Remaining object addresses:\n" );
18851885 for (op = refchain ._ob_next ; op != & refchain ; op = op -> _ob_next )
18861886 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 );
18881888}
18891889
18901890PyObject *
@@ -2025,7 +2025,7 @@ _PyTrash_deposit_object(PyObject *op)
20252025
20262026 _PyObject_ASSERT (op , PyObject_IS_GC (op ));
20272027 _PyObject_ASSERT (op , !_PyObject_GC_IS_TRACKED (op ));
2028- _PyObject_ASSERT (op , op -> ob_refcnt == 0 );
2028+ _PyObject_ASSERT (op , Py_REFCNT ( op ) == 0 );
20292029 _PyGCHead_SET_PREV (_Py_AS_GC (op ), gcstate -> trash_delete_later );
20302030 gcstate -> trash_delete_later = op ;
20312031}
@@ -2037,7 +2037,7 @@ _PyTrash_thread_deposit_object(PyObject *op)
20372037 PyThreadState * tstate = _PyThreadState_GET ();
20382038 _PyObject_ASSERT (op , PyObject_IS_GC (op ));
20392039 _PyObject_ASSERT (op , !_PyObject_GC_IS_TRACKED (op ));
2040- _PyObject_ASSERT (op , op -> ob_refcnt == 0 );
2040+ _PyObject_ASSERT (op , Py_REFCNT ( op ) == 0 );
20412041 _PyGCHead_SET_PREV (_Py_AS_GC (op ), tstate -> trash_delete_later );
20422042 tstate -> trash_delete_later = op ;
20432043}
@@ -2064,7 +2064,7 @@ _PyTrash_destroy_chain(void)
20642064 * assorted non-release builds calling Py_DECREF again ends
20652065 * up distorting allocation statistics.
20662066 */
2067- _PyObject_ASSERT (op , op -> ob_refcnt == 0 );
2067+ _PyObject_ASSERT (op , Py_REFCNT ( op ) == 0 );
20682068 ++ gcstate -> trash_delete_nesting ;
20692069 (* dealloc )(op );
20702070 -- gcstate -> trash_delete_nesting ;
@@ -2102,7 +2102,7 @@ _PyTrash_thread_destroy_chain(void)
21022102 * assorted non-release builds calling Py_DECREF again ends
21032103 * up distorting allocation statistics.
21042104 */
2105- _PyObject_ASSERT (op , op -> ob_refcnt == 0 );
2105+ _PyObject_ASSERT (op , Py_REFCNT ( op ) == 0 );
21062106 (* dealloc )(op );
21072107 assert (tstate -> trash_delete_nesting == 1 );
21082108 }
0 commit comments