diff options
author | Victor Stinner <vstinner@python.org> | 2021-04-28 13:46:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-28 13:46:57 (GMT) |
commit | 77db337f1e69213e62ba79a797540cc4ac23492e (patch) | |
tree | 3c3807e1972611e7973abceca791498417d8834e /Objects | |
parent | 7f7cfc41185b651be9cb4d2759c40c3abf738485 (diff) | |
download | cpython-77db337f1e69213e62ba79a797540cc4ac23492e.zip cpython-77db337f1e69213e62ba79a797540cc4ac23492e.tar.gz cpython-77db337f1e69213e62ba79a797540cc4ac23492e.tar.bz2 |
bpo-43962: Fix _PyInterpreterState_IDIncref() (GH-25683) (GH-25686)
_PyInterpreterState_IDIncref() now calls
_PyInterpreterState_IDInitref() and always increments id_refcount.
(cherry picked from commit 32c5a174445ec93747240cd8472012276ed27acf)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/interpreteridobject.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Objects/interpreteridobject.c b/Objects/interpreteridobject.c index 94f5dd7..19e86a2 100644 --- a/Objects/interpreteridobject.c +++ b/Objects/interpreteridobject.c @@ -23,15 +23,21 @@ newinterpid(PyTypeObject *cls, int64_t id, int force) } } + if (interp != NULL) { + if (_PyInterpreterState_IDIncref(interp) < 0) { + return NULL; + } + } + interpid *self = PyObject_New(interpid, cls); if (self == NULL) { + if (interp != NULL) { + _PyInterpreterState_IDDecref(interp); + } return NULL; } self->id = id; - if (interp != NULL) { - _PyInterpreterState_IDIncref(interp); - } return self; } |