Skip to content

Commit 702fc1e

Browse files
committed
Merge branch 'master' of https://github.com/pybind/pybind11 into py-contains-raise-unhashable
2 parents acf0e47 + 8781daf commit 702fc1e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

include/pybind11/pytypes.h

Lines changed: 3 additions & 3 deletions
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
}
@@ -1829,7 +1829,7 @@ class capsule : public object {
18291829
// guard if destructor called while err indicator is set
18301830
error_scope error_guard;
18311831
auto destructor = reinterpret_cast<void (*)(void *)>(PyCapsule_GetContext(o));
1832-
if (PyErr_Occurred()) {
1832+
if (destructor == nullptr && PyErr_Occurred()) {
18331833
throw error_already_set();
18341834
}
18351835
const char *name = get_name_in_error_scope(o);
@@ -1843,7 +1843,7 @@ class capsule : public object {
18431843
}
18441844
});
18451845

1846-
if (!m_ptr || PyCapsule_SetContext(m_ptr, (void *) destructor) != 0) {
1846+
if (!m_ptr || PyCapsule_SetContext(m_ptr, reinterpret_cast<void *>(destructor)) != 0) {
18471847
throw error_already_set();
18481848
}
18491849
}

0 commit comments

Comments
 (0)