Skip to content

Commit 8781daf

Browse files
authored
chore: Optimize iterator advance() call (#4237)
1 parent 0927c4d commit 8781daf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/pybind11/pytypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,7 @@ class iterator : public object {
13821382
private:
13831383
void advance() {
13841384
value = reinterpret_steal<object>(PyIter_Next(m_ptr));
1385-
if (PyErr_Occurred()) {
1385+
if (value.ptr() == nullptr && PyErr_Occurred()) {
13861386
throw error_already_set();
13871387
}
13881388
}

0 commit comments

Comments
 (0)