8000 bpo-42972: Fully implement GC protocol for re types by erlend-aasland · Pull Request #26368 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-42972: Fully implement GC protocol for re types #26368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 27, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Address review: visit members in order, use tp_free, don't clear weak…
… refs in tp_clear
  • Loading branch information
Erlend E. Aasland committed May 27, 2021
commit 8ae8b625177420bed7f8618245a7e94664042863
26 changes: 13 additions & 13 deletions Modules/_sre.c
3896
Original file line number Diff line number Diff line change
Expand Up @@ -566,19 +566,16 @@ pattern_error(Py_ssize_t status)
static int
pattern_traverse(PatternObject *self, visitproc visit, void *arg)
{
Py_VISIT(Py_TYPE(self));
Py_VISIT(self->groupindex);
Py_VISIT(self->indexgroup);
Py_VISIT(self->pattern);
Py_VISIT(Py_TYPE(self));
return 0;
}

static int
pattern_clear(PatternObject *self)
{
if (self->weakreflist != NULL) {
PyObject_ClearWeakRefs((PyObject *) self);
}
Py_CLEAR(self->groupindex);
Py_CLEAR(self->indexgroup);
Py_CLEAR(self->pattern);
Expand All @@ -591,8 +588,11 @@ pattern_dealloc(PatternObject* self)
PyTypeObject *tp = Py_TYPE(self);

PyObject_GC_UnTrack(self);
if (self->weakreflist != NULL) {
PyObject_ClearWeakRefs((PyObject *) self);
}
(void)pattern_clear(self);
PyObject_GC_Del(self);
tp->tp_free(self);
Py_DECREF(tp);
}

Expand Down Expand Up @@ -1961,19 +1961,19 @@ _validate(PatternObject *self)
static int
match_traverse(MatchObject *self, visitproc visit, void *arg)
{
Py_VISIT(self->pattern);
Py_VISIT(self->regs);
Py_VISIT(self->string);
Py_VISIT(Py_TYPE(self));
Py_VISIT(self->string);
Py_VISIT(self->regs);
Py_VISIT(self->pattern);
return 0;
}

static int
match_clear(MatchObject *self)
{
Py_CLEAR(self->pattern);
Py_CLEAR(self->regs);
Py_CLEAR(self->string);
Py_CLEAR(self->regs);
Py_CLEAR(self->pattern);
return 0;
}

Expand All @@ -1984,7 +1984,7 @@ match_dealloc(MatchObject* self)

PyObject_GC_UnTrack(self);
(void)match_clear(self);
PyObject_GC_Del(self);
tp->tp_free(self);
Py_DECREF(tp);
}

Expand Down Expand Up @@ -2487,8 +2487,8 @@ pattern_new_match(_sremodulestate* module_state,
static int
scanner_traverse(ScannerObject *self, visitproc visit, void *arg)
{
Py_VISIT(self->pattern);
Py_VISIT(Py_TYPE(self));
Py_VISIT(self->pattern);
return 0;
}

Expand All @@ -2507,7 +2507,7 @@ scanner_dealloc(ScannerObject* self)
PyObject_GC_UnTrack(self);
state_fini(&self->state);
(void)scanner_clear(self);
PyObject_GC_Del(self);
tp->tp_free(self);
Py_DECREF(tp);
}

Expand Down
0