Skip to content

Commit 98afa03

Browse files
authored
pythongh-149282: Fix gc.c compilation with --enable-pystats (python#149283)
1 parent e214324 commit 98afa03

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

Python/gc.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,10 +1456,14 @@ gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason)
14561456
assert(generation >= 0 && generation < NUM_GENERATIONS);
14571457

14581458
#ifdef Py_STATS
1459-
if (_Py_stats) {
1460-
_Py_stats->object_stats.object_visits = 0;
1459+
{
1460+
PyStats *s = _PyStats_GET();
1461+
if (s) {
1462+
s->object_stats.object_visits = 0;
1463+
}
14611464
}
14621465
#endif
1466+
14631467
GC_STAT_ADD(generation, collections, 1);
14641468

14651469
struct gc_generation_stats stats = { 0 };
@@ -1617,12 +1621,16 @@ gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason)
16171621

16181622
/* Update stats */
16191623
add_stats(gcstate, generation, &stats);
1620-
GC_STAT_ADD(generation, objects_collected, m);
1624+
GC_STAT_ADD(generation, objects_collected, stats.collected);
1625+
16211626
#ifdef Py_STATS
1622-
if (_Py_stats) {
1623-
GC_STAT_ADD(generation, object_visits,
1624-
_Py_stats->object_stats.object_visits);
1625-
_Py_stats->object_stats.object_visits = 0;
1627+
{
1628+
PyStats *s = _PyStats_GET();
1629+
if (s) {
1630+
GC_STAT_ADD(generation, object_visits,
1631+
s->object_stats.object_visits);
1632+
s->object_stats.object_visits = 0;
1633+
}
16261634
}
16271635
#endif
16281636

0 commit comments

Comments
 (0)