@@ -733,7 +733,9 @@ class generic_iterator : public Policy {
733
733
generic_iterator () = default ;
734
734
generic_iterator (handle seq, ssize_t index ) : Policy (seq, index ) { }
735
735
736
+ // NOLINTNEXTLINE(readability-const-return-type) // PR #3263
736
737
reference operator *() const { return Policy::dereference (); }
738
+ // NOLINTNEXTLINE(readability-const-return-type) // PR #3263
737
739
reference operator [](difference_type n) const { return *(*this + n); }
738
740
pointer operator ->() const { return **this ; }
739
741
@@ -773,11 +775,12 @@ class sequence_fast_readonly {
773
775
protected:
774
776
using iterator_category = std::random_access_iterator_tag;
775
777
using value_type = handle;
776
- using reference = const handle;
778
+ using reference = const handle; // PR #3263
777
779
using pointer = arrow_proxy<const handle>;
778
780
779
781
sequence_fast_readonly (handle obj, ssize_t n) : ptr(PySequence_Fast_ITEMS(obj.ptr()) + n) { }
780
782
783
+ // NOLINTNEXTLINE(readability-const-return-type) // PR #3263
781
784
reference dereference () const { return *ptr; }
782
785
void increment () { ++ptr; }
783
786
void decrement () { --ptr; }
@@ -816,12 +819,13 @@ class dict_readonly {
816
819
protected:
817
820
using iterator_category = std::forward_iterator_tag;
818
821
using value_type = std::pair<handle, handle>;
819
- using reference = const value_type;
822
+ using reference = const value_type; // PR #3263
820
823
using pointer = arrow_proxy<const value_type>;
821
824
822
825
dict_readonly () = default ;
823
826
dict_readonly (handle obj, ssize_t pos) : obj(obj), pos(pos) { increment (); }
824
827
828
+ // NOLINTNEXTLINE(readability-const-return-type) // PR #3263
825
829
reference dereference () const { return {key, value}; }
826
830
void increment () {
827
831
if (PyDict_Next (obj.ptr (), &pos, &key, &value) == 0 ) {
@@ -966,7 +970,7 @@ class iterator : public object {
966
970
using iterator_category = std::input_iterator_tag;
967
971
using difference_type = ssize_t ;
968
972
using value_type = handle;
969
- using reference = const handle;
973
+ using reference = const handle; // PR #3263
970
974
using pointer = const handle *;
971
975
972
976
PYBIND11_OBJECT_DEFAULT (iterator, object, PyIter_Check)
@@ -982,6 +986,7 @@ class iterator : public object {
982
986
return rv;
983
987
}
984
988
989
+ // NOLINTNEXTLINE(readability-const-return-type) // PR #3263
985
990
reference operator *() const {
986
991
if (m_ptr && !value.ptr ()) {
987
992
auto & self = const_cast <iterator &>(*this );
@@ -1414,14 +1419,19 @@ class capsule : public object {
1414
1419
T* get_pointer () const {
1415
1420
auto name = this ->name ();
1416
1421
T *result = static_cast <T *>(PyCapsule_GetPointer (m_ptr, name));
1417
- if (!result) pybind11_fail (" Unable to extract capsule contents!" );
1422
+ if (!result) {
1423
+ PyErr_Clear ();
1424
+ pybind11_fail (" Unable to extract capsule contents!" );
1425
+ }
1418
1426
return result;
1419
1427
}
1420
1428
1421
1429
// / Replaces a capsule's pointer *without* calling the destructor on the existing one.
1422
1430
void set_pointer (const void *value) {
1423
- if (PyCapsule_SetPointer (m_ptr, const_cast <void *>(value)) != 0 )
1431
+ if (PyCapsule_SetPointer (m_ptr, const_cast <void *>(value)) != 0 ) {
1432
+ PyErr_Clear ();
1424
1433
pybind11_fail (" Could not set capsule pointer" );
1434
+ }
1425
1435
}
1426
1436
1427
1437
const char *name () const { return PyCapsule_GetName (m_ptr); }
0 commit comments