Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The facts: * PyTuple_Pack returns a new reference [1]. * nrn_type_from_metaclass calls either: - PyType_FromMetaclass - PyType_FromSpecWithBases * PyType_FromSpecWithBases doesn't state that it steals `bases` [2]. * PyType_FromMetaclass doesn't state that it steals `bases` [3]. * nrn_type_from_metaclass is called in a loop. Therefore, using "local"/"relative" reference counts, i.e. the number of INCREFs that can't be paired up with a DECREF is: * After `PyTuple_Pack` it's at `+1`. * After `Py_INCREF` it's at `+2`. * After `nrn_type_from_metaclass` it stays the same: `+2`. * After `Py_DECREF` it drops to `+1`. The new version is: * After `nb::steal` we're at `+0` due to the dtor of `bases`. * Calling `nrn_type_from_metaclass` doesn't change the relative reference count: `+0`. [1]: https://docs.python.org/3/c-api/type.html#c.PyTuple_Pack [2]: https://docs.python.org/3/c-api/type.html#c.PyType_FromMetaclass [3]: https://docs.python.org/3/c-api/type.html#c.PyType_FromSpecWithBases
- Loading branch information