diff options
author | Victor Stinner <vstinner@python.org> | 2021-04-28 11:40:44 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-28 11:40:44 (GMT) |
commit | 32c5a174445ec93747240cd8472012276ed27acf (patch) | |
tree | 4543061a1faff9636786507ef6edc69bc1a66692 /Objects/interpreteridobject.c | |
parent | 21b02b5f4018474620676be04310f7d230a464ea (diff) | |
download | cpython-32c5a174445ec93747240cd8472012276ed27acf.zip cpython-32c5a174445ec93747240cd8472012276ed27acf.tar.gz cpython-32c5a174445ec93747240cd8472012276ed27acf.tar.bz2 |
bpo-43962: Fix _PyInterpreterState_IDIncref() (GH-25683)
_PyInterpreterState_IDIncref() now calls
_PyInterpreterState_IDInitref() and always increments id_refcount.
Diffstat (limited to 'Objects/interpreteridobject.c')
-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 39bde97..4623910 100644 --- a/Objects/interpreteridobject.c +++ b/Objects/interpreteridobject.c @@ -24,15 +24,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; } |