Skip to content

Commit 15de97d

Browse files
author
Joe Jevnik
committed
BUG: ensure interator type stays alive
1 parent 9c9f210 commit 15de97d

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

include/libpy/autoclass.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,13 +1157,12 @@ class autoclass_impl {
11571157
iter_name += "::iterator";
11581158

11591159
// create the iterator class and put it in the cache
1160-
if (!autoclass<iter>(std::move(iter_name), Py_TPFLAGS_HAVE_GC)
1161-
.add_slot(Py_tp_iternext, static_cast<iternextfunc>(iternext))
1162-
.add_slot(Py_tp_iter, &PyObject_SelfIter)
1163-
.template traverse<&iter::traverse>()
1164-
.type()) {
1165-
throw py::exception{};
1166-
}
1160+
autoclass<iter>(std::move(iter_name), Py_TPFLAGS_HAVE_GC)
1161+
.add_slot(Py_tp_iternext, static_cast<iternextfunc>(iternext))
1162+
.add_slot(Py_tp_iter, &PyObject_SelfIter)
1163+
.template traverse<&iter::traverse>()
1164+
.type()
1165+
.escape();
11671166

11681167
return [](PyObject* self) -> PyObject* {
11691168
try {

0 commit comments

Comments
 (0)